feat: Initial search implementation using pagefind.
This commit is contained in:
24
content/static/main.js
Normal file
24
content/static/main.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const documents = null;
|
||||
|
||||
var loadDocuments = function () {
|
||||
fetch("/static/search.json")
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to load search index.");
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((response) => (this.documents = response))
|
||||
.catch((error) => console.error(error));
|
||||
};
|
||||
|
||||
let miniSearch = new MiniSearch({
|
||||
fields: ["title", "body"],
|
||||
storeFields: ["title", "url"],
|
||||
});
|
||||
|
||||
loadDocuments();
|
||||
|
||||
console.log(documents);
|
||||
|
||||
miniSearch.addAll(documents);
|
||||
Reference in New Issue
Block a user