diff --git a/server/routes/api/posts.js b/server/routes/api/posts.js
index 6785879..7509328 100644
--- a/server/routes/api/posts.js
+++ b/server/routes/api/posts.js
@@ -56,9 +56,9 @@ routes.set('/:id', async (req, res) => {
else res.send(results[0])
})
-// For the sitemap.xml, will be listed in the XML Sitemap Index
-routes.set('/urls', async (req, res) => {
- const re = /(\/api\/)?(.*)\/urls/g
+// Dynamic RSS feed
+routes.set('/rss.xml', async (req, res) => {
+ const re = /(\/api\/)?(.*)\/rss/g
const result = [...req.raw.originalUrl.matchAll(re)]
if (!result) {
notFoundResponse(res)
@@ -67,17 +67,24 @@ routes.set('/urls', async (req, res) => {
const endpoint = result [1] ? result[1][2] : result[0][2]
// Assumes https
- const BASE_URL = 'https://' + req.raw.hostname + endpoint
- const urls = posts.map(post =>
- `\n
- ${BASE_URL}?post=${post._id}
- ${post.date}
- never
- 0.9
- `
+ const BASE_URL = 'https://' + req.raw.hostname + endpoint
+ const ITEMS = posts.map(post =>
+ `\r\n -
+ ${post.title}
+ https://${req.raw.hostname}/posts?post=${post._id}
+ https://${req.raw.hostname}/posts?post=${post._id}
+ ${post.content}
+
`
).join("\n")
- const xml = `\r
- ${urls}\n\r`
+ const xml = `\n
+
+
+ Posts
+ https://${req.raw.hostname}
+ Personal blog
+ en-us
+ ${ITEMS}
+ \n`
res.header('Content-Type', 'application/xml')
res.status(200).send(xml)