Skip to content

Commit 396d936

Browse files
committed
feat: add search using pagefind
1 parent f3e1324 commit 396d936

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

content/search/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- placeholder -->

layouts/search/list.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- define "head" -}}
2+
<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
3+
<script src="/pagefind/pagefind-ui.js"></script>
4+
5+
6+
{{- end -}}
7+
8+
{{- define "main" -}}
9+
<main data-pagefind-ignore style="width: 100%">
10+
<div id="search"></div>
11+
</main>
12+
<script>
13+
window.addEventListener('DOMContentLoaded', (event) => {
14+
new PagefindUI({ element: "#search", showSubResults: true });
15+
});
16+
</script>
17+
{{- end -}}

scripts/serve.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
set -eu;
3+
rm -rf ./public
4+
hugo --gc --buildDrafts
5+
mkdir -p ./static/
6+
rm -rf ./static/pagefind
7+
pagefind --site ./public --output-path ./static/pagefind --root-selector main
8+
hugo serve --buildDrafts --navigateToChanged
9+

0 commit comments

Comments
 (0)