Skip to content

Exclude code from the Pagefind search index#306

Open
Zneeky wants to merge 2 commits into
masterfrom
pagefind-improvements
Open

Exclude code from the Pagefind search index#306
Zneeky wants to merge 2 commits into
masterfrom
pagefind-improvements

Conversation

@Zneeky

@Zneeky Zneeky commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Waits: IgniteUI/igniteui-astro-components#74

Summary

Registers the rehype-pagefind-ignore plugin (shipped by
igniteui-astro-components) in the rehype pipeline so Pagefind stops indexing
code. This is the build side half of the search improvements; the search UI
changes live in the igniteui-astro-components package.

Why

Pagefind indexes all text inside <main>, including highlighted code. Code is
full of one letter tokens such as the generic T or the escape \t. When a
query has no strong match, Pagefind falls back to weak prefix matching and
latches onto those single characters, so a search for "twitter" returned many
unrelated API pages, with code fragments as the excerpts.

What changed

Two lines in src/integration.ts:

  • import rehypePagefindIgnore from igniteui-astro-components/plugins/rehype-pagefind-ignore
  • add it to the rehypePlugins array in createDocsSite

The plugin marks fenced code blocks and single character inline code with
data-pagefind-ignore, so matches and excerpts come from real prose. Multi
character inline code such as dataSource stays indexed and searchable.

Register the rehype-pagefind-ignore plugin from igniteui-astro-components in
the rehype pipeline. It marks code blocks and single character inline code
with data-pagefind-ignore so Pagefind stops indexing their one letter tokens,
which were producing weak, irrelevant prefix matches (for example a search for
"twitter" matching the "t" in "keyof T" across unrelated API pages).
@Zneeky Zneeky added the status: ❌ awaiting-test PR ready for testing label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ❌ awaiting-test PR ready for testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant