mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-05-15 06:58:50 +02:00
fix: use one-shot flag for pagefind instead of incremental guard
The --incremental CLI flag sets incremental=true in eleventy.after even for the watcher's first full build, so pagefind was never running when the initial build was OOM-killed. Replace the incremental guard with a pagefindDone boolean that runs pagefind exactly once per process lifetime — whichever build completes first (initial or watcher) gets indexed.
This commit is contained in:
+11
-5
@@ -663,11 +663,15 @@ export default function (eleventyConfig) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Post-build hook: pagefind indexing + WebSub notification
|
// Post-build hook: pagefind indexing + WebSub notification
|
||||||
// Runs after every full build (initial + watcher's first build), skips incremental rebuilds
|
// Pagefind runs once on the first build (initial or watcher's first full build), then never again.
|
||||||
|
// WebSub runs on every non-incremental build.
|
||||||
|
// Note: --incremental CLI flag sets incremental=true even for the watcher's first full build,
|
||||||
|
// so we cannot use the incremental flag to guard pagefind. Use a one-shot flag instead.
|
||||||
|
let pagefindDone = false;
|
||||||
eleventyConfig.on("eleventy.after", async ({ dir, directories, runMode, incremental }) => {
|
eleventyConfig.on("eleventy.after", async ({ dir, directories, runMode, incremental }) => {
|
||||||
if (incremental) return;
|
// Pagefind indexing — run exactly once per process lifetime
|
||||||
|
if (!pagefindDone) {
|
||||||
// Pagefind indexing — use directories.output (reflects --output CLI flag)
|
pagefindDone = true;
|
||||||
const outputDir = directories?.output || dir.output;
|
const outputDir = directories?.output || dir.output;
|
||||||
try {
|
try {
|
||||||
console.log(`[pagefind] Indexing ${outputDir} (${runMode})...`);
|
console.log(`[pagefind] Indexing ${outputDir} (${runMode})...`);
|
||||||
@@ -679,8 +683,10 @@ export default function (eleventyConfig) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[pagefind] Indexing failed:", err.message);
|
console.error("[pagefind] Indexing failed:", err.message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WebSub hub notification — notify subscribers of feed updates
|
// WebSub hub notification — skip on incremental rebuilds
|
||||||
|
if (incremental) return;
|
||||||
const hubUrl = "https://websubhub.com/hub";
|
const hubUrl = "https://websubhub.com/hub";
|
||||||
const feedUrls = [
|
const feedUrls = [
|
||||||
`${siteUrl}/`,
|
`${siteUrl}/`,
|
||||||
|
|||||||
Reference in New Issue
Block a user