From fdd94e6e7be90ded512d58741238d86544f19c21 Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Sat, 21 Mar 2026 06:00:07 -0700 Subject: [PATCH 1/6] feat(docs): improve search with pagination, section badges, and Pagefind tuning Phase 1 of docs search improvements: - W1.1: Add pagefind.yml with exclude_selectors and longer excerpts (200 chars) - W1.2: Add data-pagefind-meta section attributes to DocsLayout and blog layout, add data-pagefind-weight=2 to h2/h3 via rehype plugin, add data-pagefind-ignore to nav, footer, sidebar, and pre elements - W1.3: Increase search result limit from 8 to 25, add Previous/Next pagination, show result count (e.g. Showing 1-25 of 47 results) - W1.4: Display section badges on search results sourced from Pagefind metadata, styled with Tailwind color-coded badges per section Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/astro.config.mjs | 2 + docs/pagefind.yml | 13 ++ docs/src/components/Footer.astro | 2 +- docs/src/components/Header.astro | 4 +- docs/src/components/Search.astro | 151 +++++++++++++++++---- docs/src/components/Sidebar.astro | 1 + docs/src/layouts/DocsLayout.astro | 8 +- docs/src/pages/blog/[...slug].astro | 2 +- docs/src/plugins/rehype-pagefind-attrs.mjs | 21 +++ 9 files changed, 175 insertions(+), 29 deletions(-) create mode 100644 docs/pagefind.yml create mode 100644 docs/src/plugins/rehype-pagefind-attrs.mjs diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index ab9860bd3..cdc2b79dd 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -1,6 +1,7 @@ import { defineConfig } from 'astro/config'; import tailwindcss from '@tailwindcss/vite'; import { remarkRewriteLinks } from './src/plugins/remark-rewrite-links.mjs'; +import { rehypePagefindAttrs } from './src/plugins/rehype-pagefind-attrs.mjs'; export default defineConfig({ site: 'https://bradygaster.github.io', @@ -10,6 +11,7 @@ export default defineConfig({ }, markdown: { remarkPlugins: [remarkRewriteLinks], + rehypePlugins: [rehypePagefindAttrs], shikiConfig: { themes: { light: 'github-light', diff --git a/docs/pagefind.yml b/docs/pagefind.yml new file mode 100644 index 000000000..d12387c93 --- /dev/null +++ b/docs/pagefind.yml @@ -0,0 +1,13 @@ +# Pagefind configuration for Squad docs +# See: https://pagefind.app/docs/config-options/ + +# Exclude navigation, footers, and code blocks from indexing +exclude_selectors: + - "nav" + - "footer" + - "aside" + - "pre" + - ".astro-code" + +# Longer excerpts for better search result context +excerpt_length: 200 diff --git a/docs/src/components/Footer.astro b/docs/src/components/Footer.astro index f44ae621e..e7ffa8e88 100644 --- a/docs/src/components/Footer.astro +++ b/docs/src/components/Footer.astro @@ -4,7 +4,7 @@ import squadLogo from '../assets/images/squad-logo.png'; const base = import.meta.env.BASE_URL; --- -