From f2cc855f3d850ccaa888b793ffc42f3ed24154a7 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Fri, 20 Feb 2026 13:18:16 +0100 Subject: [PATCH] fix: move pagefind indexing to start.sh for reliability The eleventy.after hook was unreliable for pagefind because: 1. When the initial build is OOM-killed, the hook never fires 2. When the watcher starts with --incremental, the hook receives incremental=true even for the first full build, skipping pagefind Pagefind is now run explicitly by start.sh after the initial Eleventy build succeeds, with a recovery process for OOM-killed builds. The hook retains WebSub hub notification only. --- eleventy.config.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/eleventy.config.js b/eleventy.config.js index 79a813a..69b9503 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -622,22 +622,12 @@ export default function (eleventyConfig) { } }); - // Pagefind indexing + WebSub hub notification after each build (skip on incremental rebuilds) - eleventyConfig.on("eleventy.after", async ({ dir, directories, runMode, incremental }) => { + // WebSub hub notification after each full build (skip on incremental rebuilds) + // Note: Pagefind indexing is handled by start.sh for reliability (eleventy.after + // is unreliable when the initial build is OOM-killed or when --incremental flag + // causes the hook to skip even on the watcher's first full build) + eleventyConfig.on("eleventy.after", async ({ incremental }) => { if (incremental) return; - // Use directories.output (reflects --output CLI flag) instead of dir.output (config default) - const outputDir = directories?.output || dir.output; - // Pagefind indexing - try { - console.log(`[pagefind] Indexing ${outputDir} (${runMode})...`); - execFileSync("npx", ["pagefind", "--site", outputDir, "--output-subdir", "pagefind", "--glob", "**/*.html"], { - stdio: "inherit", - timeout: 60000, - }); - console.log("[pagefind] Indexing complete"); - } catch (err) { - console.error("[pagefind] Indexing failed:", err.message); - } // WebSub hub notification — notify subscribers of feed updates const hubUrl = "https://websubhub.com/hub";