Skip to content

Commit 802cbb4

Browse files
authored
Upgrade pagefind (#2048)
## Changes - Update Pagefind (the library that implements the search on the site) - Enable the "Pagefind Playground" ## Context The [recently-released new version](https://github.com/Pagefind/pagefind/releases/tag/v1.4.0) of Pagefind sports a pretty neat [Playground](https://pagefind.app/docs/playground/) for experimenting with the search parameters (to optimize them for better search results). I mentioned this [here](#2046 (comment)), and don't want to derail the _highly_ desirable effort to refresh the website, therefore I'll not even mention it _there_ that I opened this PR. @jvns @To1ne FYI this is the PR to upgrade Pagefind and enable the Playground.
2 parents acf3f12 + a348237 commit 802cbb4

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

.github/actions/deploy-to-github-pages/action.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ runs:
8383
8484
- name: run Pagefind ${{ env.PAGEFIND_VERSION }} to build the search index
8585
shell: bash
86-
run: npx -y pagefind@${{ env.PAGEFIND_VERSION }} --site public
86+
run: npx -y pagefind@${{ env.PAGEFIND_VERSION }} --site public --write-playground
8787

8888
- name: upload GitHub Pages artifact
8989
uses: actions/upload-pages-artifact@v3
@@ -107,10 +107,33 @@ runs:
107107
-H "Content-Type: application/json" \
108108
-d '{ "purge_everything": true }'
109109
110-
- name: construct `--remap` options for lychee
110+
- name: construct `--remap` options, root-dir for lychee
111111
id: remap
112112
shell: bash
113113
run: |
114+
# Prepare the root-dir for use with the `--root-dir` option
115+
echo "root-dir-arg=$PWD/root-dir" >>$GITHUB_OUTPUT &&
116+
case "$base_url" in
117+
https://*/?*|http://*/?*)
118+
# The base URL is not at the top-level of the URL
119+
subdir="${base_url#http*://*/}"
120+
target="root-dir/${subdir%/}"
121+
source="$(echo "${subdir%/}" | sed 's/[^/]*/../g')/public"
122+
mkdir -p "${target%/*}" &&
123+
ln -s "$source" "$target" &&
124+
echo "root-dir=$target/" >>$GITHUB_OUTPUT
125+
;;
126+
https://*|http://*)
127+
# The base URL is at the top-level of the URL
128+
ln -s public root-dir &&
129+
echo 'root-dir=root-dir/' >>$GITHUB_OUTPUT
130+
;;
131+
*)
132+
echo "::error::Unexpected base_url '$base_url'" >&2
133+
echo exit 1
134+
;;
135+
esac || exit
136+
114137
echo "result=$(echo "$base_url" |
115138
sed 's|^\(.*\)\(/git-scm\.com\)$|^(\1)?\2(.*)|') file://$PWD/public\$2" \
116139
>>$GITHUB_OUTPUT
@@ -144,7 +167,7 @@ runs:
144167
args: >-
145168
--offline
146169
--fallback-extensions html
147-
--base '${{ env.base_url }}'
170+
--root-dir '${{ steps.remap.outputs.root-dir-arg }}'
148171
--remap '${{ steps.remap.outputs.result }}'
149172
${{ steps.remap.outputs.remap-dotdot }}
150173
${{ steps.remap.outputs.remap-git-scm }}
@@ -155,7 +178,7 @@ runs:
155178
--exclude file:///Pfad/zum/Repo.git/
156179
--exclude file:///chemin/du/d%C3%A9p%C3%B4t.git/
157180
--exclude file:///srv/git/project.git
158-
public/
181+
'${{ steps.remap.outputs.root-dir }}'
159182
output: lychee.md
160183
jobSummary: true
161184
fail: false

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
fi
3434
3535
- name: run Pagefind ${{ env.PAGEFIND_VERSION }} to build the search index
36-
run: npx -y pagefind@${{ env.PAGEFIND_VERSION }} --site public
36+
run: npx -y pagefind@${{ env.PAGEFIND_VERSION }} --site public --write-playground
3737

3838
- name: build tar archive
3939
run: cd public && tar czvf ../pages.tar.gz *

hugo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module:
3232
target: content
3333
params:
3434
hugo_version: 0.148.2
35-
pagefind_version: 1.3.0
35+
pagefind_version: 1.4.0
3636
latest_version: 2.51.0
3737
latest_relnote_url: https://raw.github.com/git/git/master/Documentation/RelNotes/2.51.0.adoc
3838
latest_release_date: '2025-08-18'

0 commit comments

Comments
 (0)