diff --git a/sitegin/pipeline.js b/sitegin/pipeline.js index 5c5780d5ceaf0d53bc97325e1a59a107d55e8f75..b1e249dc1bb55d965d19aa2bb3cbd0a9950f7eed 100644 --- a/sitegin/pipeline.js +++ b/sitegin/pipeline.js @@ -10,6 +10,7 @@ module.exports = function(jobs) { 'parseHugo', 'gitInfo', 'urls', + 'sitemap', 'markdown', 'tags', 'theme', diff --git a/sitegin/sitegin.js b/sitegin/sitegin.js index 8b7de6a1cbea959a62a5e2712943d1fb48d2b53c..be2db35498cf1df569226721e30bc8fee169fd6c 100644 --- a/sitegin/sitegin.js +++ b/sitegin/sitegin.js @@ -16,6 +16,7 @@ module.exports = function(config) { ['urls', './urls'], ['writeFiles', './writeFiles'], ['resetJobs', './resetJobs'], + ['sitemap', './sitemap'], ['pipeline','./pipeline'] ) diff --git a/sitegin/sitemap.js b/sitegin/sitemap.js new file mode 100644 index 0000000000000000000000000000000000000000..af09456d22257f95b250a3266c5f831b5e1e5870 --- /dev/null +++ b/sitegin/sitemap.js @@ -0,0 +1,20 @@ +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); + }) + }); +}