mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
Fix wrong sitemap for alternate URL (#828)
This commit is contained in:
parent
9c070f020d
commit
3566483aa5
5 changed files with 45 additions and 13 deletions
|
@ -16,6 +16,7 @@ async function execute() {
|
|||
const readMetadata = require('./readMetadata.js');
|
||||
const path = require('path');
|
||||
const getTOC = require('../core/getTOC.js');
|
||||
const utils = require('../core/utils.js');
|
||||
const React = require('react');
|
||||
const mkdirp = require('mkdirp');
|
||||
const glob = require('glob');
|
||||
|
@ -164,7 +165,7 @@ async function execute() {
|
|||
// replace any links to markdown files to their website html links
|
||||
Object.keys(mdToHtml).forEach(function(key, index) {
|
||||
let link = mdToHtml[key];
|
||||
link = siteConfig.cleanUrl ? link.replace(/\.html$/, '') : link;
|
||||
link = utils.getPath(link, siteConfig.cleanUrl);
|
||||
link = link.replace('/en/', '/' + language + '/');
|
||||
link = link.replace(
|
||||
'/VERSION/',
|
||||
|
@ -205,9 +206,10 @@ async function execute() {
|
|||
env.translation.enabled &&
|
||||
metadata.permalink.indexOf('docs/en') !== -1
|
||||
) {
|
||||
const redirectlink = siteConfig.cleanUrl
|
||||
? metadata.permalink.replace(/\.html$/, '')
|
||||
: metadata.permalink;
|
||||
const redirectlink = utils.getPath(
|
||||
metadata.permalink,
|
||||
siteConfig.cleanUrl
|
||||
);
|
||||
const redirectComp = (
|
||||
<Redirect
|
||||
metadata={metadata}
|
||||
|
|
|
@ -17,6 +17,7 @@ function execute(port, options) {
|
|||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const getTOC = require('../core/getTOC');
|
||||
const utils = require('../core/utils');
|
||||
const {
|
||||
blogRouting,
|
||||
docsRouting,
|
||||
|
@ -226,7 +227,7 @@ function execute(port, options) {
|
|||
// replace any links to markdown files to their website html links
|
||||
Object.keys(mdToHtml).forEach(function(key, index) {
|
||||
let link = mdToHtml[key];
|
||||
link = siteConfig.cleanUrl ? link.replace(/\.html$/, '') : link;
|
||||
link = utils.getPath(link, siteConfig.cleanUrl);
|
||||
link = link.replace('/en/', '/' + language + '/');
|
||||
link = link.replace(
|
||||
'/VERSION/',
|
||||
|
|
|
@ -11,6 +11,7 @@ const glob = require('glob');
|
|||
const CWD = process.cwd();
|
||||
|
||||
const sitemap = require('sitemap');
|
||||
const utils = require('../core/utils');
|
||||
|
||||
const siteConfig = require(CWD + '/siteConfig.js');
|
||||
|
||||
|
@ -67,9 +68,7 @@ module.exports = function(callback) {
|
|||
|
||||
MetadataBlog.map(blog => {
|
||||
urls.push({
|
||||
url:
|
||||
'/blog/' +
|
||||
(siteConfig.cleanUrl ? blog.path.replace(/\.html$/, '') : blog.path),
|
||||
url: '/blog/' + utils.getPath(blog.path, siteConfig.cleanUrl),
|
||||
changefreq: 'weekly',
|
||||
priority: 0.3,
|
||||
});
|
||||
|
@ -79,14 +78,13 @@ module.exports = function(callback) {
|
|||
.filter(key => Metadata[key].language === 'en')
|
||||
.map(key => {
|
||||
let doc = Metadata[key];
|
||||
let docUrl = utils.getPath(doc.permalink, siteConfig.cleanUrl);
|
||||
let links = enabledLanguages.map(lang => {
|
||||
let langUrl = doc.permalink.replace('docs/en/', `docs/${lang.tag}/`);
|
||||
let langUrl = docUrl.replace('docs/en/', `docs/${lang.tag}/`);
|
||||
return {lang: lang.tag, url: langUrl};
|
||||
});
|
||||
urls.push({
|
||||
url: siteConfig.cleanUrl
|
||||
? doc.permalink.replace(/\.html$/, '')
|
||||
: doc.permalink,
|
||||
url: docUrl,
|
||||
changefreq: 'hourly',
|
||||
priority: 1.0,
|
||||
links,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue