Documentation
¶
Overview ¶
Package search builds a static full-text search index from exported HTML pages and ships a small client script that queries it in the browser.
It reads the same data-pagefind-body, data-pagefind-ignore, data-pagefind-meta, data-pagefind-default-meta and data-pagefind-index-attrs attributes as Pagefind, so markup written for Pagefind indexes unchanged. Ranking is BM25 over words and word prefixes, with title words weighted 5x and heading words 2x, and excerpts highlight matches with <mark>.
The index is one JSON file, /_search/index.json. Above ShardSize it splits into per-letter term files and page-text chunks that the client loads on demand. The client, /_search/client.js, uses no eval, inline handlers or inline styles, so it runs under a strict CSP that allows 'self'.
Index ¶
Constants ¶
const Dir = "/_search/"
Dir is the URL directory the index and the client are served from.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
File is one file of the built index, with Path relative to the site root, such as "_search/index.json".
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is a built search index.
func Build ¶
Build indexes pages. A page that fails to parse, or that has no data-pagefind-body while another page has one, is left out.
type Option ¶
type Option func(*config)
Option configures Build.
func Exclude ¶
Exclude leaves out pages whose path matches one of globs, with the same syntax as Include. It wins over Include.