Web/node/sitemap.js

52 lines
1 KiB
JavaScript
Raw Normal View History

const {
createSitemap
} = require('sitemap');
const fs = require("fs");
2020-04-02 21:54:20 +02:00
let folder = __dirname + "/../";
console.log("Refreshing sitemap...");
2020-04-02 21:54:20 +02:00
let sitemap = createSitemap({
hostname: 'https://ellpeck.de',
urls: [{
url: '/',
priority: 0.8
},
{
url: '/#projects',
changefreq: 'monthly'
},
{
url: '/#social',
changefreq: 'yearly'
},
{
url: '/#about',
changefreq: 'monthly'
},
{
url: '/#blog',
changefreq: 'weekly',
priority: 0.6
},
{
url: '/foefrenzy',
priority: 0.7
},
{
url: '/foefrenzy/maps'
}
]
});
2020-04-02 21:54:20 +02:00
fs.readFile(folder + "blog/posts.json", function (_, data) {
let json = JSON.parse(data);
2020-04-02 21:54:20 +02:00
for (let post of json) {
sitemap.add({
url: "/blog-" + post.id
});
}
2020-04-02 21:54:20 +02:00
fs.writeFile(folder + "/sitemap.xml", sitemap.toXML(), function (_, _) {});
});