September 22, 2024 8.05PM
Replaced my previous hand rolled site search that bruteforced an ungainly blob of JSON. Opted for pagefind as I knew I wanted to stick with static search that I can compile at buildtime. Will tweak styles later but you can see it working already at the search page.
Much faster and more robust.
By default it grabs the title from the first <h1>
on the page which strikes me
as odd, and doesn’t work for because not all my pages — like those I call
nonsense — have a <h1
>, so I added one of its data attributes
to the title element in my document head template and set the result icon to my
site favicon for all pages that have no images:
<head>
{% block head -%}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="The humble hands of Silas" />
<meta data-pagefind-default-meta="image[content]" content="/favicon.png" />
<title data-pagefind-meta="title">
{%- block title -%}
{% if page -%}
{{ page.title -}}
Added dependency: pagefind
Removed dependency: my terrible javascript skills