{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.1.json","id":"generators-orama-db","path":"/generators/orama-db","type":"module","module":"generators-orama-db","title":"Search index","introducedIn":null,"sourceLink":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `orama-db` generator builds the search index behind the\n[website](https://doc-kit.nodejs.org/generators/html)'s search box: an\n[Orama](https://github.com/oramasearch/orama) database with one document per\nheading in your docs. Build it alongside `html` whenever your site should have\nsearch.","summary":"The `orama-db` generator builds the search index behind the website's search box: an Orama database with one document per heading in your docs. Build it alongside `html` whenever your site should have search.","examples":[],"children":[{"kind":"section","id":"usage","name":"Usage","title":"Usage","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"```bash\nnpx @doc-kit/cli generate -t html -t orama-db -i \"docs/**/*.md\" -o out\n```\n\nBuilding both in one run adds a search box to the site's navigation bar, which\nCtrl+K or Cmd+K also opens.","summary":"Building both in one run adds a search box to the site's navigation bar, which Ctrl+K or Cmd+K also opens.","examples":[{"language":"bash","displayName":null,"code":"npx @doc-kit/cli generate -t html -t orama-db -i \"docs/**/*.md\" -o out"}],"children":[]},{"kind":"section","id":"configuring","name":"Configuring","title":"Configuring","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`orama-db` has no options of its own. It reads the\n[global options](https://doc-kit.nodejs.org/configuration#global-options).\nKeep its `output` the site's output directory, since the search box loads the\nindex from the site root.","summary":"`orama-db` has no options of its own. It reads the global options. Keep its `output` the site's output directory, since the search box loads the index from the site root.","examples":[],"children":[]},{"kind":"section","id":"what-gets-indexed","name":"What gets indexed","title":"What gets indexed","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The index holds one document per heading on every page, that is, one per\n[API entry](https://doc-kit.nodejs.org/generators/metadata). Each document has\nfour string fields:\n\n| Field         | What it holds                                                                                                                                                                                                                                                                          |\n| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `title`       | The heading's name, prefixed with the names of the headings it sits under (except the page title) and joined with `>`, as in `Kitten > meow`. An API heading contributes only the API's name (`meow` for `kitten.meow([volume])`); other headings keep their inline code in backticks. |\n| `description` | The first paragraph under the heading, with inline code kept in backticks. Left out when the section has no paragraph.                                                                                                                                                                 |\n| `href`        | The page's path from the site root, with `.html` and the heading's anchor.                                                                                                                                                                                                             |\n| `siteSection` | The page's title (its first heading). Search results are grouped by it.                                                                                                                                                                                                                |\n\nFor example, this page:\n\n```md displayName=\"docs/kittens.md\"\n# Kittens\n\nEverything about `Kitten` objects.\n\n## Class: `Kitten`\n\nA small cat.\n\n### `kitten.meow([volume])`\n\n- `volume` {number} How loud. **Default:** `1`.\n\nMakes the kitten meow.\n\n## Care\n\n- Feed twice a day.\n```\n\nbecomes these four documents, which `orama-db.json` stores along with Orama's\nsearch indexes:\n\n```json\n[\n  {\n    \"title\": \"Kittens\",\n    \"description\": \"Everything about `Kitten` objects.\",\n    \"href\": \"/kittens.html#kittens\",\n    \"siteSection\": \"Kittens\"\n  },\n  {\n    \"title\": \"Kitten\",\n    \"description\": \"A small cat.\",\n    \"href\": \"/kittens.html#class-kitten\",\n    \"siteSection\": \"Kittens\"\n  },\n  {\n    \"title\": \"Kitten > meow\",\n    \"description\": \"Makes the kitten meow.\",\n    \"href\": \"/kittens.html#kittenmeowvolume\",\n    \"siteSection\": \"Kittens\"\n  },\n  {\n    \"title\": \"Care\",\n    \"href\": \"/kittens.html#care\",\n    \"siteSection\": \"Kittens\"\n  }\n]\n```\n\nThe `meow` description skips the parameter list and takes the paragraph after\nit, and `Care` has no description because its section holds only a list.","summary":"The index holds one document per heading on every page, that is, one per API entry. Each document has four string fields:","examples":[{"language":"md","displayName":"docs/kittens.md","code":"# Kittens\n\nEverything about `Kitten` objects.\n\n## Class: `Kitten`\n\nA small cat.\n\n### `kitten.meow([volume])`\n\n- `volume` {number} How loud. **Default:** `1`.\n\nMakes the kitten meow.\n\n## Care\n\n- Feed twice a day."},{"language":"json","displayName":null,"code":"[\n  {\n    \"title\": \"Kittens\",\n    \"description\": \"Everything about `Kitten` objects.\",\n    \"href\": \"/kittens.html#kittens\",\n    \"siteSection\": \"Kittens\"\n  },\n  {\n    \"title\": \"Kitten\",\n    \"description\": \"A small cat.\",\n    \"href\": \"/kittens.html#class-kitten\",\n    \"siteSection\": \"Kittens\"\n  },\n  {\n    \"title\": \"Kitten > meow\",\n    \"description\": \"Makes the kitten meow.\",\n    \"href\": \"/kittens.html#kittenmeowvolume\",\n    \"siteSection\": \"Kittens\"\n  },\n  {\n    \"title\": \"Care\",\n    \"href\": \"/kittens.html#care\",\n    \"siteSection\": \"Kittens\"\n  }\n]"}],"children":[]},{"kind":"section","id":"querying-it-yourself","name":"Querying it yourself","title":"Querying it yourself","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`orama-db.json` is an Orama database saved with Orama's `save()`, so you can\nload it with [`@orama/orama`](https://www.npmjs.com/package/@orama/orama) to\nbuild a search of your own in the browser:\n\n```js displayName=\"search.mjs\"\nimport { create, load, search } from '@orama/orama';\n\nconst db = create({ schema: {} });\nconst data = await fetch('/orama-db.json').then(response => response.json());\n\nload(db, data);\n\nconst { hits } = await search(db, { term: 'meow' });\n```\n\nEach hit's `document` has the fields above; resolve its `href` against your\nsite's root. A generator of your own that names\n`'@doc-kit/generator-react/orama-db'` in its `dependsOn` receives the same\nsaved database (see\n[Creating generators](https://doc-kit.nodejs.org/creating-generators)).","summary":"`orama-db.json` is an Orama database saved with Orama's `save()`, so you can load it with `@orama/orama` to build a search of your own in the browser:","examples":[{"language":"js","displayName":"search.mjs","code":"import { create, load, search } from '@orama/orama';\n\nconst db = create({ schema: {} });\nconst data = await fetch('/orama-db.json').then(response => response.json());\n\nload(db, data);\n\nconst { hits } = await search(db, { term: 'meow' });"}],"children":[]}]}