Add the search page

This commit is contained in:
Sameer Rahmani 2022-10-09 19:14:56 +01:00
parent ac474ceccc
commit db577a69ea
4 changed files with 13 additions and 4 deletions

6
Makefile Normal file
View File

@ -0,0 +1,6 @@
build:
hugo -D
npm run index
clean:
rm -rf public
rm -v $(shell find . -iname "*~")

4
content/search.md Normal file
View File

@ -0,0 +1,4 @@
---
title: "Search"
layout: "search"
---

View File

@ -1,6 +1,6 @@
{ {
"scripts": { "scripts": {
"index": "hugo-lunr" "index": "mkdir -p public/db && hugo-lunr -i 'content/**' -o public/db/db.json"
}, },
"dependencies": { "dependencies": {
"hugo-lunr": "^0.0.4" "hugo-lunr": "^0.0.4"

View File

@ -1,4 +1,4 @@
et fuse let fuse
const fuseOptions = { const fuseOptions = {
shouldSort: true, shouldSort: true,
includeMatches: true, includeMatches: true,
@ -17,8 +17,7 @@ const fuseOptions = {
} }
window.onload = function () { window.onload = function () {
console.log("dvfdj") fetch('/db/db.json')
fetch('/index.json')
.then(resp => resp.json()) .then(resp => resp.json())
.then(data => { .then(data => {
fuse = new Fuse(data, fuseOptions) fuse = new Fuse(data, fuseOptions)