Navigation and search

By @lucasdicioccio, 190 words, 0 code snippets, 2 links, 0images.

Every documentation page comes with the list of all the pages of the documentation and with a search box. There is nothing to write for either of them: both are built from the pages that use the documentation layout.

The list of pages

The sidebar lists the titles of the pages, by group, in the order of the documentation. The page being read is highlighted. On a narrow screen the list moves above the content, folded.

The search box of the header looks for the typed words in the documentation pages only: their titles, their headings and their text. A result leads to the heading under which the words were found, not merely to the page.

Press / to jump to the search box, use the arrow keys to pick a result and Enter to open it.

The search index

The search runs in the browser. It needs the doc-search.js script, which a site started with kitchen-sink init has (copy it from the website-src directory of Kitchen-Sink otherwise), and it reads /json/doc-search.json, a file produced for any site that has documentation pages. That file has one entry for the introduction of each page and one entry per heading, each with its url, title, group, heading and text.