Hawk adds a keyboard-accessible search palette to a static site using its Pagefind index. Theme and animation plugins let the palette match the site.
πTable of Contents
- Pagefind-backed β chunked, lazily-loaded, typo-tolerant search index.
- Scale-safe result hydration β bounded concurrent fragment loading and progressive rendering keep Hawk's network and DOM work predictable for both small and very large indexes.
- Developer-configured tabs β auto-derived category pills, or explicit Pagefind-filter tabs.
- Fit / medium / compact density modes with a slideout control and a saved preference.
- Two-pane keyboard navigation β Tab between input, filters, results, and preview.
- Configurable layout β scale, position, offset, columns, and a JS-driven breakpoint.
- Theme and animation plugin systems β a TypeFlow typewriter driver ships built-in, alongside a zero-dependency instant driver.
- Search operators β narrow results with
tags:API,author:"Ada Lovelace", orfilter:category=Guides, and change order withsort:date:desc. - Result metadata β dates, tags, related pages, and a pin system, each independently themeable and configurable.
- Built-in trigger element and Pagefind attribution, so no hand-built markup is required.
- Accessible by default β a real modal focus trap, graceful fallback if Pagefind fails to
load, and full i18n via
config.strings.
See Resources below for the full feature reference.
npm install @staticcanvas/hawk
npm install --save-dev pagefind
# Optional: the official TypeFlow animation driver
npm install @staticcanvas/typeflowpagefind is a real dependency (hawk has nothing to search without an index).
@staticcanvas/typeflow is an optional peer dependency β only needed when importing Hawk's
official TypeFlow animation adapter. Hawk core and the TypeFlow visual theme remain independent.
import { HawkSearch } from '@staticcanvas/hawk';
import '@staticcanvas/hawk/css';
new HawkSearch({
index: '/pagefind/',
preload: true,
trigger: { container: 'body' },
});preload: true warms Pagefind and the initial results during idle time after page load.
Remove it to load search on first use.
The Result density button beside Escape slides Fit, Medium, and Compact out to the left.
Hawk remembers the visitor's choice. Set headerControls.density.layout to 'inline' for
always-visible buttons or 'dropdown' for a vertical list. Set headerControls.density to
false to hide the size control while keeping Escape.
Try tags: Pagefind sort:date:desc to browse tagged pages newest first. A space after an
operator's colon shows a badge while you type its value. Edit the badge as ordinary input text.
category:guides matches Guides regardless of case. Use case:category=Guides to require exact
case. Result dates are hidden by default. Set showResultDate: true to show them.
The default TypeFlow preview reveal animates only visible content. The rest of the preview is ready to scroll as soon as the page content loads.
Hawk hydrates Pagefind result fragments in ordered batches: up to 6 requests run concurrently,
the first completed batch renders immediately, and loading stops once maxResults is filled.
Large or exclusion-heavy indexes are bounded to maxCandidateResults candidates (by default,
three times maxResults). Both limits are configurable; see the
API reference.
trigger renders Hawk's own search button. See Getting started
in the docs for the full TypeFlow-themed setup, frontmatter/metadata mapping, and every config
option.
git clone https://github.com/staticcanvas/hawk.git
cd hawk
npm install
npm run build # core + optional (theme-typeflow, animation-typeflow, debug, metrics) bundles
npm test # vitest, jsdomTo build and preview the docs site itself (Hugo + Pagefind, requires
Hugo on PATH):
npm run docs:serveSee Development & NPM Scripts for the full script reference.
Hawk's development and distribution are supported by these services:
- jsDelivr β open-source CDN delivery.
- UNPKG β CDN delivery for npm packages.
- npm β package registry and distribution.
- JSR β JavaScript and TypeScript package registry.
- Shields.io β project and status badges.
- GitHub β source hosting, CI/CD, releases, and documentation hosting.
- Codecov β test coverage reporting.
- Documentation: https://staticcanvas.github.io/hawk/
- Playground: https://staticcanvas.github.io/hawk/playground/
- API reference:
docs/content/api.md - Guides: Pagefind setup, tabs, and inline filters Β· Density and keyboard navigation Β· Theming Β· Animation plugins Β· Pins, the built-in trigger, and attribution
- Architecture:
architecture/README.md(design rationale) Β·plugin-system.mdΒ·theme-interface.mdΒ·animation-driver-interface.md - Changelog:
CHANGELOG.md - Issues: https://github.com/staticcanvas/hawk/issues
Contributions are welcome. For a substantial change, first open an issue to discuss the proposal. For smaller fixes:
-
Fork the project, then clone your fork:
git clone https://github.com/YOUR_USERNAME/hawk.git. -
Enter the checkout:
cd hawk. -
Install the locked dependencies:
npm ci. -
Create a branch from
develop:git switch develop && git switch -c feature/feature-name. -
Make your changes, then run
npm run lintandnpm test. -
Commit and push:
git commit -m 'Add feature name' && git push -u origin feature/feature-name. -
Open a pull request targeting
develop:
| Script | Purpose |
|---|---|
npm run dev |
Vite dev server |
npm run serve:demo |
Opens the local web utility demo in Vite |
npm run build |
Builds core + optional (theme-typeflow, animation-typeflow, debug, metrics) bundles |
npm run dev:typeflow |
Builds hawk and copies the bundle + a preview Pagefind index into the sibling typeflow checkout's docs site, for live prototyping |
npm run pagefind:index |
Wraps pagefind --site <dir> β see scripts/pagefind-index.mjs |
npm test / npm run test:coverage |
Vitest (jsdom) β unit coverage |
npm run test:bun / npm run test:coverage:bun |
Bun test runner, with optional coverage |
npm run test:e2e |
Playwright, real Chromium against a real built docs site + Pagefind index (not a fixture) β builds the docs site with a localhost baseURL override first. Runs as a required browser check in GitHub Actions. |
npm run lint / npm run lint:fix |
ESLint |
npm run format |
Formats the repository with Prettier |
npm run docs:build / npm run docs:serve |
Builds and serves hawk's own Hugo docs site |
npm run themes:css |
Generates one small standalone CSS file per gallery/template theme into docs/static/assets/themes/ β see scripts/generate-theme-css.mjs |
npm run docs:scss |
Compiles docs/static/assets/scss/*.scss into docs/static/assets/docs.css/playground.css β see scripts/compile-docs-scss.mjs. Also runs automatically as part of docs:build/docs:serve |
npm run check:size |
Enforces the gzip bundle size budget |
npm run check:jsr |
Validates the JSR package configuration and dry-run contents |
npm run validate:release |
CI release-artifact validation |
npm run check:quality |
Builds, checks the bundle size, and runs the Vitest suite |
npm run bench:size |
Compares bundle sizes against a selected Git reference |
Distributed under the MIT License. See LICENSE for details.
CI and release setup is documented in GitHub Actions.