From a39b20375d14e4e07772e85cda794001a219ae2e Mon Sep 17 00:00:00 2001 From: Ricardo Date: Mon, 2 Mar 2026 13:40:33 +0100 Subject: [PATCH] fix: make starred page client-side rendered to avoid OOM 5,137 starred repos in Nunjucks template + Pagefind indexing exceeded the 2048MB Eleventy heap limit during build. Switched to Alpine.js client-side rendering: - _data/githubStarred.js: returns only buildDate (no API fetch) - starred.njk: fetches /githubapi/api/starred/all via Alpine.js - Added client-side text search (replaces separate Pagefind index) - Removed pagefind-starred build step and --exclude-selectors flag Confab-Link: http://localhost:8080/sessions/b130e9e5-4723-435d-8d5a-fc38113381c9 --- _data/githubStarred.js | 48 ++----- eleventy.config.js | 23 +-- starred.njk | 320 +++++++++++++++++++++-------------------- 3 files changed, 177 insertions(+), 214 deletions(-) diff --git a/_data/githubStarred.js b/_data/githubStarred.js index 1707538..ababab2 100644 --- a/_data/githubStarred.js +++ b/_data/githubStarred.js @@ -1,44 +1,12 @@ /** - * GitHub Starred Repos Data - * Fetches all cached starred repos from Indiekit's GitHub endpoint - * Uses EleventyFetch with 1-day cache (plugin handles freshness) + * GitHub Starred Repos Metadata + * Provides build timestamp only — the starred page fetches all data + * client-side via Alpine.js to avoid loading 5000+ objects into + * Eleventy's memory during build (causes OOM on constrained containers). */ -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", - }; - } +export default function () { + return { + buildDate: new Date().toISOString(), + }; } diff --git a/eleventy.config.js b/eleventy.config.js index e9de5b4..5b5eac3 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -36,9 +36,6 @@ 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"); eleventyConfig.ignores.add("interactive/**"); @@ -50,8 +47,6 @@ 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"); @@ -1043,7 +1038,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", "--exclude-selectors", ".starred-card"], { + execFileSync("npx", ["pagefind", "--site", outputDir, "--output-subdir", "pagefind", "--glob", "**/*.html"], { stdio: "inherit", timeout: 120000, }); @@ -1052,22 +1047,6 @@ export default function (eleventyConfig) { 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/starred.njk b/starred.njk index b3c5659..6445691 100644 --- a/starred.njk +++ b/starred.njk @@ -5,7 +5,7 @@ permalink: /github/starred/ eleventyExcludeFromCollections: true --- -
+
← GitHub Activity @@ -17,175 +17,191 @@ eleventyExcludeFromCollections: true Starred Repositories

- {{ githubStarred.totalCount | default("0") }} repos starred on GitHub. - {% if githubStarred.lastSync %} - Last synced {{ githubStarred.lastSync | date("PPp") }}. - {% endif %} + + +

- {# Search — separate Pagefind index for starred repos #} -
- - -
- - {# Live updates — new stars since last build #} -
-

- - Recently Starred - -

-
-