From fa7bfb26ea8848869f7d476687fbd3d481b77993 Mon Sep 17 00:00:00 2001 From: rmdes Date: Sat, 21 Feb 2026 21:56:15 +0100 Subject: [PATCH] feat: add comment system components and recent comments widget - Comment area on post pages (IndieAuth sign-in, submit, display) - Alpine.js client-side component for auth flow and comment CRUD - Recent comments sidebar widget with build-time data fetching - Include comments.js in base layout, comments.njk before webmentions Co-Authored-By: Claude Opus 4.6 --- _data/recentComments.js | 24 +++ _includes/components/blog-sidebar.njk | 2 + _includes/components/comments.njk | 94 ++++++++++++ .../components/widgets/recent-comments.njk | 25 +++ _includes/layouts/base.njk | 2 + _includes/layouts/post.njk | 3 + js/comments.js | 143 ++++++++++++++++++ 7 files changed, 293 insertions(+) create mode 100644 _data/recentComments.js create mode 100644 _includes/components/comments.njk create mode 100644 _includes/components/widgets/recent-comments.njk create mode 100644 js/comments.js diff --git a/_data/recentComments.js b/_data/recentComments.js new file mode 100644 index 0000000..bdd1ede --- /dev/null +++ b/_data/recentComments.js @@ -0,0 +1,24 @@ +/** + * Recent Comments Data + * Fetches the 5 most recent comments at build time for the sidebar widget. + */ + +import EleventyFetch from "@11ty/eleventy-fetch"; + +const INDIEKIT_URL = process.env.SITE_URL || "https://example.com"; + +export default async function () { + try { + const url = `${INDIEKIT_URL}/comments/api/comments?limit=5`; + console.log(`[recentComments] Fetching: ${url}`); + const data = await EleventyFetch(url, { + duration: "15m", + type: "json", + }); + console.log(`[recentComments] Got ${(data.children || []).length} comments`); + return data.children || []; + } catch (error) { + console.log(`[recentComments] Unavailable: ${error.message}`); + return []; + } +} diff --git a/_includes/components/blog-sidebar.njk b/_includes/components/blog-sidebar.njk index 799b5aa..2ac1d85 100644 --- a/_includes/components/blog-sidebar.njk +++ b/_includes/components/blog-sidebar.njk @@ -32,6 +32,8 @@ {% include "components/widgets/feedland.njk" %} {% elif widget.type == "categories" %} {% include "components/widgets/categories.njk" %} + {% elif widget.type == "recent-comments" %} + {% include "components/widgets/recent-comments.njk" %} {% elif widget.type == "search" %}