added a sitemap generator, let's see if this works
This commit is contained in:
parent
9ee1e22192
commit
c44b72ffb9
2 changed files with 50 additions and 0 deletions
49
node/sitemap.js
Normal file
49
node/sitemap.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
const express = require('express');
|
||||
const {
|
||||
createSitemap
|
||||
} = require('sitemap');
|
||||
const fs = require("fs");
|
||||
|
||||
let app = express();
|
||||
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
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/sitemap.xml', function (_req, res) {
|
||||
let xml = sitemap.toXML();
|
||||
res.header('Content-Type', 'application/xml');
|
||||
res.send(xml);
|
||||
});
|
||||
app.listen(3000);
|
1
robots.txt
Normal file
1
robots.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Sitemap: https://ellpeck.de/sitemap.xml
|
Loading…
Reference in a new issue