Skip to content
Snippets Groups Projects
Verified Commit b3703f5f authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Generate sitemap.xml

parent 294a54fe
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ module.exports = function(jobs) {
'parseHugo',
'gitInfo',
'urls',
'sitemap',
'markdown',
'tags',
'theme',
......
......@@ -16,6 +16,7 @@ module.exports = function(config) {
['urls', './urls'],
['writeFiles', './writeFiles'],
['resetJobs', './resetJobs'],
['sitemap', './sitemap'],
['pipeline','./pipeline']
)
......
var fs = require('fs');
module.exports = function(obj) {
return new Promise(function(resolve, reject) {
var file = '<?xml version="1.0" encoding="UTF-8"?>\n'+
'<urlset\n'+
'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"\n'+
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n'+
'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n';
obj.pages.forEach(function(page) {
file += '<url>\n'+
' <loc>https://ok1kvk.cz/'+page.file+'/</loc>\n'+
' <lastmod>'+page.metadata.date.modification.toISOString()+'</lastmod>\n'+
'</url>\n'
})
file += '</urlset>';
fs.writeFile(obj.config.builddir+'/sitemap.xml',file,function(){
resolve(obj);
})
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment