fix: restore pagefind to eleventy.after hook
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).
This commit is contained in:
+16
-5
@@ -662,13 +662,24 @@ export default function (eleventyConfig) {
|
|||||||
console.log(`[unfurl] Pre-fetch complete.`);
|
console.log(`[unfurl] Pre-fetch complete.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// WebSub hub notification after each full build (skip on incremental rebuilds)
|
// Post-build hook: pagefind indexing + WebSub notification
|
||||||
// Note: Pagefind indexing is handled by start.sh for reliability (eleventy.after
|
// Runs after every full build (initial + watcher's first build), skips incremental rebuilds
|
||||||
// is unreliable when the initial build is OOM-killed or when --incremental flag
|
eleventyConfig.on("eleventy.after", async ({ dir, directories, runMode, incremental }) => {
|
||||||
// causes the hook to skip even on the watcher's first full build)
|
|
||||||
eleventyConfig.on("eleventy.after", async ({ incremental }) => {
|
|
||||||
if (incremental) return;
|
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
|
// WebSub hub notification — notify subscribers of feed updates
|
||||||
const hubUrl = "https://websubhub.com/hub";
|
const hubUrl = "https://websubhub.com/hub";
|
||||||
const feedUrls = [
|
const feedUrls = [
|
||||||
|
|||||||
Reference in New Issue
Block a user