2019-10-03 18:17:50 +02:00
|
|
|
const express = require('express');
|
|
|
|
const {
|
|
|
|
createSitemap
|
|
|
|
} = require('sitemap');
|
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
let app = express();
|
2019-10-04 11:20:12 +02:00
|
|
|
app.get('/sitemap.xml', function (_req, res) {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
2019-10-03 18:17:50 +02:00
|
|
|
|
2019-10-04 11:20:12 +02:00
|
|
|
fs.readFile(__dirname + "/../blog/posts.json", function (_, data) {
|
|
|
|
var json = JSON.parse(data);
|
|
|
|
for (var post of json) {
|
|
|
|
sitemap.add({
|
|
|
|
url: "/#blog-" + post["id"],
|
|
|
|
priority: 0.4
|
|
|
|
});
|
|
|
|
}
|
2019-10-03 18:17:50 +02:00
|
|
|
|
2019-10-04 11:20:12 +02:00
|
|
|
res.header('Content-Type', 'application/xml');
|
|
|
|
res.send(sitemap.toXML());
|
|
|
|
});
|
2019-10-03 18:17:50 +02:00
|
|
|
});
|
|
|
|
app.listen(3000);
|