From 7c64b2c4cefcc0611b42939d17c977854885d917 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sun, 22 Feb 2026 00:58:53 +0100 Subject: [PATCH] fix: restore pagefind to eleventy.after hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pagefind indexing was moved to start.sh in f2cc855 but the shell-based approach is fragile: the recovery mechanism timed out when the initial build was OOM-killed, leaving no search index. The eleventy.after hook is the natural place — Eleventy knows the correct output directory and the incremental guard prevents re-indexing on watch rebuilds. Timeout increased to 120s for the larger site (2194 pages). --- eleventy.config.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/eleventy.config.js b/eleventy.config.js index 0720c7b..bd55565 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -662,13 +662,24 @@ export default function (eleventyConfig) { console.log(`[unfurl] Pre-fetch complete.`); }); - // 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 }) => { + // Post-build hook: pagefind indexing + WebSub notification + // Runs after every full build (initial + watcher's first build), skips incremental rebuilds + eleventyConfig.on("eleventy.after", async ({ dir, directories, runMode, incremental }) => { if (incremental) return; + // Pagefind indexing — use directories.output (reflects --output CLI flag) + const outputDir = directories?.output || dir.output; + try { + console.log(`[pagefind] Indexing ${outputDir} (${runMode})...`); + execFileSync("npx", ["pagefind", "--site", outputDir, "--output-subdir", "pagefind", "--glob", "**/*.html"], { + stdio: "inherit", + timeout: 120000, + }); + 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"; const feedUrls = [