Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-05-12 04:43:25 +10:00
parent 655d16ea6b
commit b09a329d62
13 changed files with 3602 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
import { MarkdownRenderer } from "./MarkdownRenderer.js";
import { BlogComments } from "./BlogComments.js";
/**
* Decodes markdown payload from a JSON script element.
@@ -65,6 +66,33 @@ function renderStaticBlogPost() {
wireCopyButtons(target);
}
/**
* Mounts Matrix-backed comments/reactions for the current blog post.
*
* @returns {Promise<void>}
*/
async function setupBlogComments() {
/** @type {HTMLElement | null} */
const mount = document.querySelector("[data-blog-comments]");
if (!mount) return;
const slug = window.location.pathname
.split("/")
.filter(Boolean)
.pop() || "unknown";
const homeserver = mount.dataset.matrixHomeserver || "https://chat.ruv.wtf";
const roomAlias = mount.dataset.matrixRoom || "#general:chat.ruv.wtf";
const comments = new BlogComments({
homeserver,
roomAlias,
postSlug: slug
});
await comments.initialize(mount);
}
/**
* Toggles the compact top bar when the hero logo scrolls out of view.
*
@@ -200,10 +228,11 @@ function setupPeekSplines() {
*
* @returns {void}
*/
function initializeBlogPage() {
async function initializeBlogPage() {
renderStaticBlogPost();
setupScrollTopBar();
setupPeekSplines();
await setupBlogComments();
}
if (document.readyState === "loading") {