aboutsummaryrefslogtreecommitdiffstats
path: root/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'server.js')
-rwxr-xr-xserver.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/server.js b/server.js
index 49b107f..6871564 100755
--- a/server.js
+++ b/server.js
@@ -99,6 +99,23 @@ function renderAndSend_v2(req, res, slug) {
});
}
+function renderTagPage(req, res, tag) {
+ model.blogPost
+ .find(
+ { keywords: { $in: [tag] } },
+ { projection: { _id: 0, title: 0, teaser: 0, body: 0, keywords: 0 } },
+ )
+ .exec(function (err, blogPosts) {
+ if (err) return err;
+ return res.render("tags.ejs", {
+ cache: true,
+ data: {
+ blogPosts: blogPosts,
+ },
+ });
+ });
+}
+
app.get("/health", (req, res) => {
res.type("application/json");
let response = { isOK: "True", error: "" };
@@ -153,6 +170,13 @@ app.get("/posts/:postName", (req, res) => {
renderAndSend_v2(req, res, req.params.postName);
});
+app.get("/tags/:tagName", (req, res) => {
+ if (req.params["tagName"] == "") {
+ res.write("nothing requested!");
+ }
+ renderTagPage(req, res, req.params.tagName);
+});
+
app.get("/$", (req, res) => {
model.blogPost
.find({}, { projection: { _id: 0, title: 0, teaser: 0 } })