diff options
| author | XhmikosR <[email protected]> | 2024-03-13 08:38:53 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2024-03-19 11:25:15 +0200 |
| commit | f7f0026e4af2fee210b664e145dfe55bd12b7deb (patch) | |
| tree | e8d89a44a7a50765cd496f495eb9617b47016d84 | |
| parent | 45fe28c5a6ed88d1a661355349aed799a79ed0fe (diff) | |
| download | bootstrap-f7f0026e4af2fee210b664e145dfe55bd12b7deb.tar.xz bootstrap-f7f0026e4af2fee210b664e145dfe55bd12b7deb.zip | |
docs: move algolia config to hugo config
| -rw-r--r-- | hugo.yml | 5 | ||||
| -rw-r--r-- | site/assets/js/search.js | 9 | ||||
| -rw-r--r-- | site/layouts/partials/header.html | 2 | ||||
| -rw-r--r-- | site/layouts/partials/scripts.html | 6 |
4 files changed, 18 insertions, 4 deletions
@@ -73,6 +73,11 @@ params: analytics: fathom_site: "ITUSEYJG" + algolia: + appId: "AK7KMZKZHQ" + apiKey: "3151f502c7b9e9dafd5e6372b691a24e" + indexName: "bootstrap" + download: source: "https://github.com/twbs/bootstrap/archive/v5.3.3.zip" dist: "https://github.com/twbs/bootstrap/releases/download/v5.3.3/bootstrap-5.3.3-dist.zip" diff --git a/site/assets/js/search.js b/site/assets/js/search.js index 95d920c44..48047abc8 100644 --- a/site/assets/js/search.js +++ b/site/assets/js/search.js @@ -10,6 +10,9 @@ */ import docsearch from '@docsearch/js' +// https://gohugo.io/hugo-pipes/js/#options +// eslint-disable-next-line import/no-unresolved +import { appId, apiKey, indexName } from '@params'; (() => { const searchElement = document.getElementById('docsearch') @@ -21,9 +24,9 @@ import docsearch from '@docsearch/js' const siteDocsVersion = searchElement.getAttribute('data-bd-docs-version') docsearch({ - apiKey: '3151f502c7b9e9dafd5e6372b691a24e', - indexName: 'bootstrap', - appId: 'AK7KMZKZHQ', + apiKey, + indexName, + appId, container: searchElement, searchParameters: { facetFilters: [`version:${siteDocsVersion}`] diff --git a/site/layouts/partials/header.html b/site/layouts/partials/header.html index 3f259ac5e..66bdf2fb1 100644 --- a/site/layouts/partials/header.html +++ b/site/layouts/partials/header.html @@ -10,7 +10,7 @@ <link rel="canonical" href="{{ .Permalink }}"> {{ if (ne .Page.Layout "examples") -}} -<link rel="preconnect" href="https://ak7kmzkzhq-dsn.algolia.net" crossorigin> +<link rel="preconnect" href="https://{{ .Site.Params.algolia.appId | lower }}-dsn.algolia.net" crossorigin> {{- end }} <title>{{ if .IsHome }}{{ .Site.Title | markdownify }} · {{ .Site.Params.subtitle | markdownify }}{{ else }}{{ .Title | markdownify }} · {{ .Site.Title | markdownify }} v{{ .Site.Params.docs_version }}{{ end }}</title> diff --git a/site/layouts/partials/scripts.html b/site/layouts/partials/scripts.html index 63889a9ea..e224c4b37 100644 --- a/site/layouts/partials/scripts.html +++ b/site/layouts/partials/scripts.html @@ -15,6 +15,12 @@ <script defer src="{{ $applicationJs.RelPermalink }}"></script> {{- if (ne .Page.Layout "examples") -}} +{{- $esbuildParams := dict + "apiKey" .Site.Params.algolia.apiKey + "appId" .Site.Params.algolia.appId + "indexName" .Site.Params.algolia.indexName +-}} +{{- $esbuildOptions = merge $esbuildOptions (dict "params" $esbuildParams) -}} {{- $searchJs := resources.Get "js/search.js" | js.Build $esbuildOptions | resources.Copy (path.Join $targetDocsJSPath "/assets/js/search.js") }} <script defer src="{{ $searchJs.RelPermalink }}"></script> {{- end -}} |
