recent comments x3
All checks were successful
Build Org Website / build (push) Successful in 52s

This commit is contained in:
2026-05-10 22:45:46 +01:00
parent 0d9b3cfbd2
commit 8328d43650
2 changed files with 8 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ function createComment(comment) {
const wrapper = document.createElement("div"); const wrapper = document.createElement("div");
wrapper.className = "comment"; wrapper.className = "comment";
wrapper.dataset.id = comment.id; wrapper.dataset.id = comment.id;
wrapper.id = `comment-${comment.id}`;
const author = document.createElement("strong"); const author = document.createElement("strong");
author.textContent = comment.author || "Anonymous"; author.textContent = comment.author || "Anonymous";

View File

@@ -144,6 +144,12 @@
return comment.created_at || comment.createdAt || ""; return comment.created_at || comment.createdAt || "";
} }
function commentHref(page, comment) {
if (!page?.url) return null;
if (!comment.id) return page.url + "#comments";
return page.url + "#comment-" + encodeURIComponent(comment.id);
}
function formatCommentDate(value) { function formatCommentDate(value) {
const date = new Date(value); const date = new Date(value);
if (Number.isNaN(date.getTime())) return ""; if (Number.isNaN(date.getTime())) return "";
@@ -182,7 +188,7 @@
const slug = commentSlug(comment); const slug = commentSlug(comment);
const page = pageMap.get(slug); const page = pageMap.get(slug);
const title = page?.title || slug || "Unknown page"; const title = page?.title || slug || "Unknown page";
const href = page?.url ? page.url + "#comments" : null; const href = commentHref(page, comment);
const author = comment.author || "Anonymous"; const author = comment.author || "Anonymous";
const date = formatCommentDate(commentDate(comment)); const date = formatCommentDate(commentDate(comment));
const pageLink = href const pageLink = href