# 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.
- An empty search lists the last five pages you opened, then the current
  page's `h2` and `h3` sections. The browser keeps the visited pages in
  `localStorage`, per site.
- Every word of the query must match. Words match by prefix; words of five
  letters or more also allow typos.
- The index holds only each example's output, not its source, so a word in an
  example matches once.

## Client

`startDocs()` from `@memomori-app/elysium/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 arrow keys scroll a code block or table that scrolls sideways instead of
turning the page, and do nothing while you select text. 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-app/elysium">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.

`createDocs` takes an `updated` option to date pages another way. It gets each
page's path inside the folder and returns a `YYYY-MM-DD` date, or `undefined`
for none, and Elysium then never runs git.
