Skip to content

Commit

Permalink
docs: move algolia config to hugo config
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 16, 2024
1 parent e15f731 commit e28541b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions site/assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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}`]
Expand Down
2 changes: 1 addition & 1 deletion site/layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions site/layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 async src="{{ $searchJs.RelPermalink }}"></script>
{{- end -}}
Expand Down

0 comments on commit e28541b

Please sign in to comment.