fix(search): only index pages on dev updates

Now that dev updates actually reach the index, any changed markdown
file was being ingested — including srcExclude'd include partials and
dynamic route templates, which are not pages and produced dead search
results. Mirror the initial scan and only index files present in
siteConfig.pages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/5014/head
Divyansh Singh 6 days ago
parent 027f0461e0
commit 559fb24a22

@ -229,9 +229,13 @@ export async function localSearchPlugin(
if (this.environment.name !== 'client') return
if (file.endsWith('.md')) {
await indexFile(slash(path.relative(siteConfig.srcDir, file)))
debug('🔍️ Updated', file)
onIndexUpdated()
const page = slash(path.relative(siteConfig.srcDir, file))
// only index actual pages, not includes or route templates
if (siteConfig.pages.includes(page)) {
await indexFile(page)
debug('🔍️ Updated', file)
onIndexUpdated()
}
}
}
}

Loading…
Cancel
Save