Configure sitemap depending on whether clean URLs enabled (#765)

* Configure sitemap depending on whether clean URLs enabled

* Run Prettier
This commit is contained in:
Joel Marcey 2018-06-12 16:00:32 -07:00 committed by Endilie Yacop Sucipto
parent a2b076bdca
commit c2ff413650

View file

@ -59,7 +59,9 @@ module.exports = function(callback) {
// create a url mapping to all the enabled languages files
files.map(file => {
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 langUrl = lang.tag + url;
return {lang: lang.tag, url: langUrl};
@ -67,11 +69,12 @@ module.exports = function(callback) {
urls.push({url, changefreq: 'weekly', priority: 0.5, links});
});
let htmlFiles = glob.sync(CWD + '/pages/**/*.html');
MetadataBlog.map(blog => {
urls.push({
url: '/blog/' + blog.path,
url:
'/blog/' + siteConfig.cleanUrl
? blog.path.replace(/\.html$/, '')
: blog.path,
changefreq: 'weekly',
priority: 0.3,
});
@ -86,7 +89,9 @@ module.exports = function(callback) {
return {lang: lang.tag, url: langUrl};
});
urls.push({
url: doc.permalink,
url: siteConfig.cleanUrl
? doc.permalink.replace(/\.html$/, '')
: doc.permalink,
changefreq: 'hourly',
priority: 1.0,
links,