]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
docs: move algolia config to hugo config
authorXhmikosR <xhmikosr@gmail.com>
Wed, 13 Mar 2024 06:38:53 +0000 (08:38 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 19 Mar 2024 09:25:15 +0000 (11:25 +0200)
hugo.yml
site/assets/js/search.js
site/layouts/partials/header.html
site/layouts/partials/scripts.html

index ba23d38c0260de44a89cb841b0e271da4d4ed955..1ff261b04228dd361d2e5ac054f72dfba826d7f8 100644 (file)
--- a/hugo.yml
+++ b/hugo.yml
@@ -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"
index 95d920c445fe9baf5474081b3f001cc1560a1601..48047abc87504b0cea7c3ab4a79e79f4d54655ef 100644 (file)
@@ -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}`]
index 3f259ac5e8424c578f36c2207b7db8fcdce01ec4..66bdf2fb1bcfc0238b7b9be92edbe0954cd90b02 100644 (file)
@@ -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>
index 63889a9eaf1816d95da2f168a35791f62354f810..e224c4b3775d1ff5b57f95653d5ac88a1cc618cd 100644 (file)
 <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 -}}