mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 16:17:25 +02:00
Configure sitemap depending on whether clean URLs enabled (#765)
* Configure sitemap depending on whether clean URLs enabled * Run Prettier
This commit is contained in:
parent
a2b076bdca
commit
c2ff413650
1 changed files with 10 additions and 5 deletions
|
@ -59,7 +59,9 @@ module.exports = function(callback) {
|
||||||
// create a url mapping to all the enabled languages files
|
// create a url mapping to all the enabled languages files
|
||||||
files.map(file => {
|
files.map(file => {
|
||||||
let url = file.split('/pages/en')[1];
|
let url = file.split('/pages/en')[1];
|
||||||
url = url.replace(/\.js$/, '.html');
|
url = siteConfig.cleanUrl
|
||||||
|
? url.replace(/\.js$/, '')
|
||||||
|
: url.replace(/\.js$/, '.html');
|
||||||
let links = enabledLanguages.map(lang => {
|
let links = enabledLanguages.map(lang => {
|
||||||
let langUrl = lang.tag + url;
|
let langUrl = lang.tag + url;
|
||||||
return {lang: lang.tag, url: langUrl};
|
return {lang: lang.tag, url: langUrl};
|
||||||
|
@ -67,11 +69,12 @@ module.exports = function(callback) {
|
||||||
urls.push({url, changefreq: 'weekly', priority: 0.5, links});
|
urls.push({url, changefreq: 'weekly', priority: 0.5, links});
|
||||||
});
|
});
|
||||||
|
|
||||||
let htmlFiles = glob.sync(CWD + '/pages/**/*.html');
|
|
||||||
|
|
||||||
MetadataBlog.map(blog => {
|
MetadataBlog.map(blog => {
|
||||||
urls.push({
|
urls.push({
|
||||||
url: '/blog/' + blog.path,
|
url:
|
||||||
|
'/blog/' + siteConfig.cleanUrl
|
||||||
|
? blog.path.replace(/\.html$/, '')
|
||||||
|
: blog.path,
|
||||||
changefreq: 'weekly',
|
changefreq: 'weekly',
|
||||||
priority: 0.3,
|
priority: 0.3,
|
||||||
});
|
});
|
||||||
|
@ -86,7 +89,9 @@ module.exports = function(callback) {
|
||||||
return {lang: lang.tag, url: langUrl};
|
return {lang: lang.tag, url: langUrl};
|
||||||
});
|
});
|
||||||
urls.push({
|
urls.push({
|
||||||
url: doc.permalink,
|
url: siteConfig.cleanUrl
|
||||||
|
? doc.permalink.replace(/\.html$/, '')
|
||||||
|
: doc.permalink,
|
||||||
changefreq: 'hourly',
|
changefreq: 'hourly',
|
||||||
priority: 1.0,
|
priority: 1.0,
|
||||||
links,
|
links,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue