Skip to content

Commit

Permalink
Configure sitemap depending on whether clean URLs enabled (#765)
Browse files Browse the repository at this point in the history
* Configure sitemap depending on whether clean URLs enabled

* Run Prettier
  • Loading branch information
JoelMarcey authored and endiliey committed Jun 12, 2018
1 parent a2b076b commit c2ff413
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/server/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,22 @@ 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};
});
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,
});
Expand All @@ -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,
Expand Down

0 comments on commit c2ff413

Please sign in to comment.