update
This commit is contained in:
parent
0fc95f7e5e
commit
e1f61e55dc
26
app.js
26
app.js
@ -105,6 +105,32 @@ app.get('/track/:slug', async (req, res) => {
|
||||
res.render('track', { track });
|
||||
});
|
||||
|
||||
// JSON endpoint to return cached tracks
|
||||
app.get('/json', async (req, res) => {
|
||||
const allTracks = await getTracks();
|
||||
res.json(allTracks);
|
||||
});
|
||||
|
||||
// Sitemap endpoint
|
||||
app.get('/sitemap.xml', async (req, res) => {
|
||||
const allTracks = await getTracks();
|
||||
let sitemap = `<?xml version="1.0" encoding="UTF-8"?>\n`;
|
||||
sitemap += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n`;
|
||||
|
||||
// Home page
|
||||
sitemap += `<url>\n <loc>https://raven-scott.rocks/</loc>\n <priority>1.0</priority>\n</url>\n`;
|
||||
|
||||
// Track pages
|
||||
allTracks.forEach(track => {
|
||||
sitemap += `<url>\n <loc>https://raven-scott.rocks/track/${track.slug}</loc>\n <priority>0.8</priority>\n</url>\n`;
|
||||
});
|
||||
|
||||
sitemap += `</urlset>`;
|
||||
|
||||
res.header('Content-Type', 'application/xml');
|
||||
res.send(sitemap);
|
||||
});
|
||||
|
||||
// Listen on the specified port
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
|
Loading…
Reference in New Issue
Block a user