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 <noreply@anthropic.com>
This commit is contained in:
24
_data/recentComments.js
Normal file
24
_data/recentComments.js
Normal file
@@ -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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user