# Search, agents and dates

## Search

Open search from the sidebar, or press <kbd>Ctrl</kbd> <kbd>K</kbd>
(<kbd>⌘</kbd> <kbd>K</kbd> on a Mac).

- The build writes `search-index.json`, with one entry per `h2` and `h3`
  section and one for each page's opening text.
- The client loads MiniSearch and the index on first use, so pages load none
  of it up front.
- Every word of the query must match. Words match by prefix; words of five
  letters or more also allow typos.
- Examples count by their output only, so a search finds a word once.

## Client

`startDocs()` from `@memomori/charon/docs/client` is the browser script. The
CLI's theme runs it for you. It:

- keeps the sidebar's scroll position between pages
- marks the current section in "On this page"
- turns to the previous or next page on <kbd>←</kbd> and <kbd>→</kbd>
- opens search on <kbd>Ctrl</kbd> <kbd>K</kbd>
- runs the copy button on each code block

The arrows leave alone a code block or table that scrolls sideways, and do
nothing while text is selected. Pass `{ arrowKeys: false }` or
`{ searchKey: false }` to turn off either key.

A `button` with a `data-copy` attribute copies that text, so you can place
copy buttons of your own:

```html
<button data-copy="npm install @memomori/charon">Copy</button>
```

## For agents and crawlers

- `llms.txt` lists every page by section, each with its description and a link
  to its Markdown copy.
- `llms-full.txt` holds every Markdown copy in one file.
- Each page has a Markdown copy at its URL plus `.md`, linked from the page as
  `rel="alternate"` and from its "View as Markdown" button. An `example` fence
  there reads as a plain `md` fence.
- `sitemap.xml` lists every page with its `lastmod`, when you set a site URL.
  Add it to your `robots.txt`.

## Last updated

`{{updated}}` and `lastmod` come from the last git commit that touched the
page's file. A page git has not seen gets neither. A build without git
history, such as a shallow clone in CI, shows the wrong date or none; fetch the
full history before you build.
