feat: Initial search implementation using pagefind.

This commit is contained in:
2025-04-06 10:40:58 -04:00
parent 6457674de7
commit 573e70a8d2
9 changed files with 104 additions and 21 deletions

24
content/static/main.js Normal file
View 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);