Skip to content

Commit 2b8e1ca

Browse files
committed
feat: use pathfind library to search
1 parent f7f4fae commit 2b8e1ca

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.github/workflows/gh-pages.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ jobs:
3434
version: v0.10.2
3535

3636
- name: Build
37-
run: zine release
37+
run: |
38+
zine release
39+
# https://gohugo.io/tools/search/
40+
# https://pagefind.app/docs/
41+
npx -y pagefind --site public --force-language zh-cn
3842
3943
- name: Upload artifact
4044
uses: actions/upload-pages-artifact@v3

layouts/templates/base.shtml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
<title :text="$page.title"></title>
88
<link type="text/css" rel="stylesheet" href="$site.asset('style.css').link()">
99
<link type="text/css" rel="stylesheet" href="$site.asset('highlight.css').link()">
10+
<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
11+
<script src="/pagefind/pagefind-ui.js"></script>
1012
<script>
13+
window.addEventListener('DOMContentLoaded', (event) => {
14+
new PagefindUI({ element: "#search", showSubResults: true });
15+
});
1116
var _hmt = _hmt || [];
1217
(function() {
1318
var hm = document.createElement("script");
@@ -38,6 +43,7 @@
3843
<a href="$site.page('contributing').link()">贡献</a>
3944
</nav>
4045
</div>
46+
<div id="search"></div>
4147
<super>
4248
<footer>
4349
<div>

0 commit comments

Comments
 (0)