Comments now have their own pages, at /comment/commentID, these are

linked to when someone replies to another comment (>> id), I also fixed
a bug in comment submission where the counter was not incrementing
This commit is contained in:
2025-07-31 03:58:28 +01:00
parent 0cc319a702
commit b683b658f7
7 changed files with 64 additions and 5 deletions

View File

@@ -216,6 +216,30 @@ app.get("/tag/:tag", (req,res) => {
converter,
})
}); // /tag/:tag
app.get("/comment/:commentID", (req,res) => {
const commentID = req.params.commentID;
const comment = func.get_comment(commentID)
if (comment == -1) {
res.render("partials/message", {
config,
message: config.string.comment_doesnt_exist,
})
}
else {
res.render("pages/comment",
{
config: config,
post: posts[comment["id"]],
users,
comment,
fromUnixTime: fromUnixTime,
format: format,
getUnixTime: getUnixTime,
func,
converter,
})
}
});
///////////////////// Form pages ////////////////////////////
@@ -275,7 +299,7 @@ app.post("/submit_comment", (req,res) => {
"id": comments.counter,
"pubdate": unix_timestamp
};
let counter = comments.counter+1;
comments.counter += 1;
comments.comments[req.body.post_index].push(new_comment);
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');