From db577a69ea451da1f4fac538ed1dddaa0b947a43 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 9 Oct 2022 19:14:56 +0100 Subject: [PATCH] Add the search page --- Makefile | 6 ++++++ content/search.md | 4 ++++ package.json | 2 +- themes/coyote/assets/js/search.js | 5 ++--- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 Makefile create mode 100644 content/search.md diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4ead78a --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +build: + hugo -D + npm run index +clean: + rm -rf public + rm -v $(shell find . -iname "*~") diff --git a/content/search.md b/content/search.md new file mode 100644 index 0000000..9da8567 --- /dev/null +++ b/content/search.md @@ -0,0 +1,4 @@ +--- +title: "Search" +layout: "search" +--- diff --git a/package.json b/package.json index d95a865..9ee8308 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "scripts": { - "index": "hugo-lunr" + "index": "mkdir -p public/db && hugo-lunr -i 'content/**' -o public/db/db.json" }, "dependencies": { "hugo-lunr": "^0.0.4" diff --git a/themes/coyote/assets/js/search.js b/themes/coyote/assets/js/search.js index 3f21eb3..d332565 100644 --- a/themes/coyote/assets/js/search.js +++ b/themes/coyote/assets/js/search.js @@ -1,4 +1,4 @@ -et fuse +let fuse const fuseOptions = { shouldSort: true, includeMatches: true, @@ -17,8 +17,7 @@ const fuseOptions = { } window.onload = function () { - console.log("dvfdj") - fetch('/index.json') + fetch('/db/db.json') .then(resp => resp.json()) .then(data => { fuse = new Fuse(data, fuseOptions)