Mix task for installing and invoking pagefind. Heavily inspired by tailwind and esbuild.
If available in Hex, the package can be installed
by adding pagefind
to your list of dependencies in mix.exs
:
def deps do
[
{:pagefind, "~> 0.1.0"}
]
end
Once installed, change your config/config.exs
and pick a version for the pagefind CLI of your choice:
config :pagefind, version: "1.3.0"
Now you can install pagefind by running:
$ mix pagefind.install
And invoke pagefind with:
$ mix pagefind --site dist --output-subdir search --exclude-selectors "#my_navigation, blockquote > span, [id^='prefix-']"
The executable is kept at _build/pagefind-TARGET
. Where TARGET
is your system target architecture.
To add pagefind
to an application using Tableau, you need only two steps:
First add a new extension which will trigger Pagefind in lib/extensions/pagefind_extension.ex
:
defmodule MyAapp.PagefindExtension do
use Tableau.Extension, enabled: true, type: :post_write, key: :search, priority: 500
def run(token) do
Pagefind.install_and_run([]);
{:ok, token}
end
end
Now let's change config/config.exs
to configure pagefind
:
config :pagefind, version: "1.3.0", args: ["--site", "_site"]
That's all.
Copyright (c) 2025 Piotr Baj.
pagefind source code is licensed under the MIT License.