Pagefind Static Search
Pagefind is a fully static search library that aims to perform well on large sites, while using as little of your users’ bandwidth as possible, and without hosting any infrastructure.
The full documentation on using Pagefind can be found at https://pagefind.app/.
This packages houses a wrapper for running the precompiled Pagefind binary, and also serves as a NodeJS indexing library that can be integrated into existing tools.
Running Pagefind through NPX
This is the recommended way of running Pagefind on a static site.
npx pagefind --site "public"
For more details on using the Pagefind binary, see Installing and running Pagefind, and the rest of the Pagefind documentation.
Using Pagefind as a Node library
This package also provides an interface to the Pagefind binary directly as a package you can import.
import * as pagefind from "pagefind";
const { index } = await pagefind.createIndex();
await index.addDirectory({
path: "public"
});
await index.addCustomRecord({
url: "/resume.pdf",
content: "Aenean lacinia bibendum nulla sed consectetur",
language: "en",
});
const { files } = await index.getFiles();
await index.writeFiles({
outputPath: "public/pagefind"
});
For more details on using Pagefind as a library, see Indexing content using the NodeJS API.
v1.0.3 (September 16, 2023)
Hopefully the last hotfix for now — bugfixes only important for sites indexing Japanese or Chinese pages.
- Fixes a bug indexing ja/zh language pages containing weighting or element IDs
- Removes eager warnings being logged to the browser console if bunding the UI JavaScript files
- Adds a
.close()
function to the Pagefind NodeJS API, to help clean up the process when it is no longer required