mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-04-02 16:44:56 +02:00
- 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>
25 lines
708 B
JavaScript
25 lines
708 B
JavaScript
/**
|
|
* 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 [];
|
|
}
|
|
}
|