diff options
author | terminaldweller <thabogre@gmail.com> | 2022-03-04 21:59:05 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-03-04 21:59:05 +0000 |
commit | 75e5102ffd532a50604f6a95864fa6a13c32c235 (patch) | |
tree | a7cca87654fcc55ec0f8f92bc451de8f46b6dc33 /server.js | |
parent | added helmet (diff) | |
download | blog-75e5102ffd532a50604f6a95864fa6a13c32c235.tar.gz blog-75e5102ffd532a50604f6a95864fa6a13c32c235.zip |
rss, WIP
Diffstat (limited to 'server.js')
-rwxr-xr-x | server.js | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -33,6 +33,10 @@ app.engine("ejs", require("ejs").__express); app.use(helmet()); app.use(morgan("combined")); +async function enumerateDir() { + return await fs.readdirSync(path.join(__dirname, "mds")); +} + function renderAndSend(req, res) { try { let viewPath; @@ -90,10 +94,13 @@ app.get("/robots.txt", (req, res) => { res.send(robots_txt); }); -// app.get("/rss/feed", (req, res) => { -// let html = pug.renderFile("./views/rss_feed.pug", merge(options, localls)); -// res.send(html); -// }); +app.get("/rss/feed", (req, res) => { + const compiledFunction = pug.compileFile("./views/rss_feed.pug"); + const files = fs.readdirSync(path.join(__dirname, "mds")); + for (const file of files) { + res.send(compiledFunction(file)); + } +}); app.get("/$", (req, res) => { renderAndSend(req, res); @@ -106,10 +113,6 @@ app.get("/mds/:mdname$", (req, res) => { renderAndSend(req, res); }); -async function enumerateDir() { - return await fs.readdirSync(path.join(__dirname, "mds")); -} - app.use(sitemap(enumerateDir, "https://blog.terminaldweller.com")); app.use((req, res) => { |