diff --git a/.gitignore b/.gitignore index 19876ab2a6..76d3b8dadb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules resources public tmp +static/pagefind diff --git a/Dockerfile b/Dockerfile index 206895b7ac..f3bbb72b0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,5 +83,15 @@ WORKDIR /test RUN --mount=type=bind,target=. \ ./scripts/test_unused_media.sh +FROM base as pagefind +ARG PAGEFIND_VERSION=1.1.0 +COPY --from=build /out ./public +RUN --mount=type=bind,src=pagefind.yml,target=pagefind.yml \ + npx pagefind@v${PAGEFIND_VERSION} --output-path "/pagefind" + +FROM scratch AS index +COPY --from=pagefind /pagefind . + FROM scratch AS release COPY --from=build /out / +COPY --from=pagefind /pagefind . diff --git a/assets/css/global.css b/assets/css/global.css index 36f68746df..45eb8a3abf 100644 --- a/assets/css/global.css +++ b/assets/css/global.css @@ -14,6 +14,10 @@ scrollbar-color: theme(colors.gray.dark.800) theme(colors.white / 0.10); } } + + mark { + @apply bg-amber-light-200 dark:bg-amber-dark-600/25 dark:text-white; + } } /* utility classes */ diff --git a/assets/js/src/search.js b/assets/js/src/search.js deleted file mode 100644 index 34fa2dbb56..0000000000 --- a/assets/js/src/search.js +++ /dev/null @@ -1,65 +0,0 @@ -import Fuse from "fuse.js"; - -let indexed = false; -let handler = null; - -const modalSearchInput = document.querySelector("#modal-search-input"); -const modalSearchResults = document.querySelector("#modal-search-results"); - -async function initializeIndex() { - const index = await fetch("/metadata.json").then((response) => - response.json(), - ); - - const options = { - keys: [ - { name: "title", weight: 2 }, - { name: "description", weight: 1 }, - { - name: "keywords", - weight: 1, - getFn: (page) => { - return Array.isArray(page.keywords) - ? page.keywords.join(" ") - : page.keywords; - }, - }, - { name: "tags", weight: 1 }, - ], - minMatchCharLength: 1, - threshold: 0.2, - ignoreLocation: true, - useExtendedSearch: true, - ignoreFieldNorm: true, - }; - - handler = new Fuse(index, options); - indexed = true; -} - -async function executeSearch(query) { - !indexed && (await initializeIndex()); - const results = handler.search(query); - return results; -} - -async function modalSearch(e) { - const query = e.target.value; - results = await executeSearch(query); - - let resultsHTML = `
${item.description}
-