Search
This guide turns the search of a site on or off, and tests it.
The search is on
Each site has a search. The build writes:
search.json, an index of the words of each page;- the page
search/, with a search box and the results; - a search box in the header of each page, from the slot
{{search}}.
The search runs in the browser of the reader. It needs no server, and no request leaves the site. The results show while the reader types.
Test it
The search page loads its index with fetch, so open the site from a server and not from the disk:
flight-manual serve
Open http://127.0.0.1:8000/search/?q=install.
Turn it off
search 0
With search 0, the build writes no index and no search page, and the slot {{search}} is empty.
Turn on the panel
panel 1
groups {Commands Guides}
With panel 1, the search field of each page drops a panel down with the best results while the reader types. The results are in groups, in the order of groups, and then the other groups in the order of the menu.
- Down and Up (also Ctrl+N and Ctrl+P) move through the results. Enter opens the selected result, or the search page with no result selected. Escape closes the panel.
/, Ctrl+K, and Cmd+K put the focus in the search field from each page.- With no JavaScript or no WebAssembly, the field is a form that goes to the search page.
The panel is a Tcl script, assets/panel.tcl, that runs in the WebAssembly build of ztcl in the browser. The script gets only the capabilities dom and event. The browser loads it, the index, and ztcl on the first use: the first focus of the field, or the first / or Ctrl+K. The first use loads about 2.7 MB, or about 1 MB compressed, from the site. No request leaves the site.
To mark a page of a plugin as a command, give it the page keys kind and usage (Plugins). An exact command name is then the first result, and the result shows its usage line.
How it finds a page
A query is a list of words. A page must have each word, and the last word can be the start of a word. The title of a page counts more than a heading, and a heading more than the text. Search has the format of the index and the rules of a query.
Next: Check a site.