diff --git a/tests/themes.spec.mjs b/tests/themes.spec.mjs
index f33fa4f..2abd0d1 100644
--- a/tests/themes.spec.mjs
+++ b/tests/themes.spec.mjs
@@ -62,13 +62,22 @@ test.describe('MkDocs theme', () => {
await page.route(/tagbrush@1/, (r) => r.fulfill({ path: 'node_modules/tagbrush/tagbrush.css', contentType: 'text/css' }));
await page.route(/tagaction@0/, (r) => r.fulfill({ path: 'node_modules/tagaction/tagaction.js', contentType: 'text/javascript' }));
await page.goto(pathToFileURL(resolve(`${SITE}/guide/install/index.html`)).href);
- await expect(page.locator('body > aside nav a[aria-current="page"]')).toHaveText('Install');
+ await expect(page.locator('body > aside nav[aria-label="Documentation"] a[aria-current="page"]')).toHaveText('Install');
await expect(page.locator('main > aside nav[aria-label="On this page"] a')).toHaveText(['Requirements', 'With pip', 'Check the install']);
await expect(page.locator('a[rel="prev"]')).toHaveText('← Home');
await expect(page.locator('a[rel="next"]')).toHaveText('Configure →');
await expect(page.getByRole('button', { name: 'Copy' })).toHaveCount(2);
await expect(page.locator('head meta[name="description"]')).toHaveAttribute('content', 'Deploy a folder of static files with one command.');
});
+
+ test('search: a box over a list of every page and section, both hidden until TagAction shows them', async () => {
+ const { readFileSync } = await import('node:fs');
+ const html = readFileSync(`${SITE}/guide/install/index.html`, 'utf8');
+ expect(html).toMatch(/ /);
+ expect(html).toMatch(/
/);
+ const results = [...html.matchAll(/([^<]+)<\/a><\/li>/g)].map((m) => m[1]);
+ for (const title of ['Install', 'Install: With pip', 'Configure: Environment variables', 'Home: Why shipit']) expect(results).toContain(title);
+ });
});
test.describe('Hugo theme', () => {
diff --git a/themes/mkdocs/README.md b/themes/mkdocs/README.md
index 2e8d2cd..9f530de 100644
--- a/themes/mkdocs/README.md
+++ b/themes/mkdocs/README.md
@@ -12,6 +12,9 @@ theme:
name: tagkit
primary_color: "#0f766e" # optional brand color
tagaction: true # false leaves out the TagAction script
+ search: titles # titles (default), pagefind, or false
+markdown_extensions:
+ - admonition # !!! note callouts
```
The page is styled by [TagBrush.css](https://github.com/kovirlabs/tagbrush) and enhanced by [TagAction](https://github.com/kovirlabs/tagaction), both loaded from a CDN.
@@ -24,10 +27,14 @@ The page is styled by [TagBrush.css](https://github.com/kovirlabs/tagbrush) and
- Tables, footnotes, and code styled by TagBrush.css; Copy buttons on code, sortable tables, and "#" links on headings from TagAction. Everything works with JavaScript off.
- `description` in a page's front matter (or `site_description`) becomes its meta description.
-## Not included (yet)
+- Search above the sidebar (see below).
+- Callouts: `!!! note`, `!!! warning`, `!!! tip` and the other admonition kinds are colored callouts (TagBrush.css 1.2 and later). Turn on the `admonition` Markdown extension, or MkDocs leaves them as plain text.
-- Search: MkDocs' search plugin needs theme JavaScript. Add `plugins: []` to skip building its index.
-- Admonitions (`!!! note`) show as plain text until TagBrush.css styles them.
+## Search
+
+- `search: titles` (the default) puts a search box above the sidebar that finds pages and their sections by title as you type. The theme writes a list of every page and `##` section into each page, and TagAction filters it, so there's no index to build and no script of its own. It needs TagAction 0.3 or later, and like everything TagAction adds, it's hidden when JavaScript is off. MkDocs' own search plugin isn't used; add `plugins: []` to skip building its index.
+- `search: pagefind` searches the full text with [Pagefind](https://pagefind.app/), which builds a static index after MkDocs: run `npx pagefind --site site` after `mkdocs build`. The theme loads Pagefind's search box from `pagefind/` and marks each page's article as the text to index.
+- `search: false` leaves search out.
## Tested
diff --git a/themes/mkdocs/mkdocs_tagkit/main.html b/themes/mkdocs/mkdocs_tagkit/main.html
index a9a9dbf..c8d38c8 100644
--- a/themes/mkdocs/mkdocs_tagkit/main.html
+++ b/themes/mkdocs/mkdocs_tagkit/main.html
@@ -20,6 +20,11 @@
{%- if config.theme.tagaction != false %}
{%- endif %}
+{%- set search = config.theme.search %}
+{%- if search == 'pagefind' %}
+
+
+{%- endif %}
{%- for path in config.extra_css %}
{%- endfor %}
@@ -31,6 +36,28 @@
{%- if nav|length > 1 %}
{%- endif %}
-
+
{{ page.content }}
{%- if page.edit_url %}
Edit this page
diff --git a/themes/mkdocs/mkdocs_tagkit/mkdocs_theme.yml b/themes/mkdocs/mkdocs_tagkit/mkdocs_theme.yml
index f39619c..bd2dc02 100644
--- a/themes/mkdocs/mkdocs_tagkit/mkdocs_theme.yml
+++ b/themes/mkdocs/mkdocs_tagkit/mkdocs_theme.yml
@@ -4,3 +4,4 @@ static_templates:
locale: en
primary_color: null # brand color for links and buttons, for example "#0f766e"
tagaction: true # false leaves out the TagAction script
+search: titles # titles: search page and section titles (needs TagAction); pagefind: full text with Pagefind; false: no search