Skip to content

Commit

Permalink
docs: add algolia versions to all content
Browse files Browse the repository at this point in the history
This PR makes sure all content gets tagged appropriately so we can be
smarter about showing relevant results.

Also added the `public` directory to the gitignore. This is created when
doing local hugo development and shouldn't be committed.

Signed-off-by: Spencer Smith <spencer.smith@talos-systems.com>
  • Loading branch information
rsmitty committed Mar 25, 2022
1 parent 5344d6e commit 67fb72d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ sha512sum.txt
package-lock.json
node_modules
website/resources
website/public
15 changes: 13 additions & 2 deletions website/layouts/partials/hooks/body-end.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{ $currentVersionDir := index (split .Page.File.Dir "/" ) 0 | printf "/%s"}}
{{ $currentVersion := index (split .Page.File.Dir "/" ) 0 }}
{{ $currentVersionDir := $currentVersion | printf "/%s"}}

<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>

<script>
Expand All @@ -15,6 +17,15 @@
</script>


<!--
tag all content with its corresponding version.
the "not equal" handles the case where there is no version on the main landing page
the "equal" handles whether we also tag this content as "latest"
-->
{{ if ne $currentVersion "" }}
{{ if eq $currentVersionDir site.Params.url_latest_version }}
<meta name="docsearch:version" content="latest" />
<meta name="docsearch:version" content="latest,{{ $currentVersion }}" />
{{else}}
<meta name="docsearch:version" content="{{ $currentVersion }}" />
{{end}}
{{ end }}

0 comments on commit 67fb72d

Please sign in to comment.