diff --git a/_data/githubStarred.js b/_data/githubStarred.js new file mode 100644 index 0000000..1707538 --- /dev/null +++ b/_data/githubStarred.js @@ -0,0 +1,44 @@ +/** + * GitHub Starred Repos Data + * Fetches all cached starred repos from Indiekit's GitHub endpoint + * Uses EleventyFetch with 1-day cache (plugin handles freshness) + */ + +import EleventyFetch from "@11ty/eleventy-fetch"; + +const INDIEKIT_URL = process.env.SITE_URL || "https://example.com"; + +export default async function () { + const buildDate = new Date().toISOString(); + + try { + const url = `${INDIEKIT_URL}/githubapi/api/starred/all`; + console.log(`[githubStarred] Fetching from: ${url}`); + + const data = await EleventyFetch(url, { + duration: "1d", + type: "json", + }); + + console.log( + `[githubStarred] Loaded ${data.stars?.length || 0} starred repos (total: ${data.totalCount})`, + ); + + return { + stars: data.stars || [], + totalCount: data.totalCount || 0, + lastSync: data.lastSync || null, + buildDate, + source: "indiekit", + }; + } catch (error) { + console.log(`[githubStarred] API unavailable: ${error.message}`); + return { + stars: [], + totalCount: 0, + lastSync: null, + buildDate, + source: "error", + }; + } +} diff --git a/eleventy.config.js b/eleventy.config.js index 483d43a..e9de5b4 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -36,6 +36,8 @@ export default function (eleventyConfig) { // Ignore Pagefind output directory eleventyConfig.ignores.add("pagefind"); eleventyConfig.ignores.add("pagefind/**"); + eleventyConfig.ignores.add("pagefind-starred"); + eleventyConfig.ignores.add("pagefind-starred/**"); // Ignore interactive assets (served via passthrough copy, not processed as templates) eleventyConfig.ignores.add("interactive"); @@ -48,6 +50,8 @@ export default function (eleventyConfig) { eleventyConfig.watchIgnores.add("/app/data/site/**"); eleventyConfig.watchIgnores.add("pagefind"); eleventyConfig.watchIgnores.add("pagefind/**"); + eleventyConfig.watchIgnores.add("pagefind-starred"); + eleventyConfig.watchIgnores.add("pagefind-starred/**"); eleventyConfig.watchIgnores.add(".cache/og"); eleventyConfig.watchIgnores.add(".cache/og/**"); eleventyConfig.watchIgnores.add(".cache/unfurl"); @@ -1039,7 +1043,7 @@ export default function (eleventyConfig) { const outputDir = directories?.output || dir.output; try { console.log(`[pagefind] Indexing ${outputDir} (${runMode})...`); - execFileSync("npx", ["pagefind", "--site", outputDir, "--output-subdir", "pagefind", "--glob", "**/*.html"], { + execFileSync("npx", ["pagefind", "--site", outputDir, "--output-subdir", "pagefind", "--glob", "**/*.html", "--exclude-selectors", ".starred-card"], { stdio: "inherit", timeout: 120000, }); @@ -1047,6 +1051,23 @@ export default function (eleventyConfig) { } catch (err) { console.error("[pagefind] Indexing failed:", err.message); } + + // Starred repos Pagefind index — separate from main site search + try { + console.log("[pagefind-starred] Indexing starred repos..."); + execFileSync("npx", [ + "pagefind", + "--site", outputDir, + "--output-subdir", "pagefind-starred", + "--glob", "github/starred/index.html", + ], { + stdio: "inherit", + timeout: 120000, + }); + console.log("[pagefind-starred] Indexing complete"); + } catch (err) { + console.error("[pagefind-starred] Indexing failed:", err.message); + } } // WebSub hub notification — skip on incremental rebuilds diff --git a/github.njk b/github.njk index 3d4dee5..5f6849c 100644 --- a/github.njk +++ b/github.njk @@ -259,6 +259,10 @@ withSidebar: true {% endfor %} + + + View all {{ githubStarred.totalCount | default(githubActivity.stars | length) }} starred repos → + {% else %}
No starred repositories found.
{% endif %} diff --git a/starred.njk b/starred.njk new file mode 100644 index 0000000..b3c5659 --- /dev/null +++ b/starred.njk @@ -0,0 +1,191 @@ +--- +layout: layouts/base.njk +title: Starred Repositories +permalink: /github/starred/ +eleventyExcludeFromCollections: true +--- + ++ {{ githubStarred.totalCount | default("0") }} repos starred on GitHub. + {% if githubStarred.lastSync %} + Last synced {{ githubStarred.lastSync | date("PPp") }}. + {% endif %} +
+{{ repo.description }}
+ {% endif %} + + {% if repo.topics.length %} +No starred repositories found. The cache may still be syncing.
+ {% endif %} +