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 = `
${results.length} results
`; - resultsHTML += results - .map(({ item }) => { - return `
-
- ${item.title} -

${item.description}

-
-
`; - }) - .join(""); - - modalSearchResults.innerHTML = resultsHTML; -} - -modalSearchInput.addEventListener("input", modalSearch); diff --git a/docker-bake.hcl b/docker-bake.hcl index 0905e1cc9c..388ccb83c8 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -17,6 +17,12 @@ group "default" { targets = ["release"] } +target "index" { + # generate a new local search index + target = "index" + output = ["type=local,dest=static/pagefind"] +} + target "release" { args = { HUGO_ENV = HUGO_ENV diff --git a/hugo_stats.json b/hugo_stats.json index eef735345d..c6e686bde3 100644 --- a/hugo_stats.json +++ b/hugo_stats.json @@ -39,6 +39,7 @@ "Docker-Engine", "Docker-Hub", "Download", + "Entra-ID", "Entra-ID-SAML-2.0", "Fedora", "For-Mac-and-Linux", @@ -54,6 +55,7 @@ "HCL", "HTTP", "Heredocs", + "Hub", "Hyper-V-backend-and-Windows-containers", "Inline", "Install-from-the-command-line", @@ -90,6 +92,7 @@ "Shell", "Specific-version", "Svelte", + "Travis-CI", "Ubuntu", "Unix-pipe", "Use-Docker-Init", diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index 2fb33f7137..3f3d37489d 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -1,4 +1,4 @@ -
+
{{ with .Attributes.title }}
{{ . }}
{{ end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index b4cc2e5726..6f6db22003 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -30,7 +30,7 @@ {{ end }}
-
+
{{ block "main" . }} {{ end }}
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 262a25aad6..98429ff1ba 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -6,7 +6,7 @@ {{ partial "breadcrumbs.html" . }}
{{ with .Title }} -

{{ . }}

+

{{ . }}

{{ end }}
{{ partial "pagemeta.html" . }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 6ca5ceb82b..8de8e490dd 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -6,7 +6,7 @@ {{ partial "breadcrumbs.html" . }}
{{ with .Title }} -

{{ . }}

+

{{ . }}

{{ end }}
{{ partial "pagemeta.html" . }} diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html index e7077aa3a6..47be24db12 100644 --- a/layouts/partials/breadcrumbs.html +++ b/layouts/partials/breadcrumbs.html @@ -2,7 +2,7 @@ {{ $ctx := . }} -