Adjust logic to mark current section for Algolia

This commit is contained in:
Bjørn Erik Pedersen 2025-02-11 17:52:44 +01:00
parent ba73ce646b
commit 769e387cd4
No known key found for this signature in database

View File

@ -3,8 +3,10 @@
<nav aria-label="breadcrumb" class="flex breadcrumbs">
<ol class="inline-flex items-center flex-wrap tracking-tight">
{{ $currentSection := .CurrentSection }}
{{ $ancestors := .Ancestors.Reverse }}
{{ range $i, $p := $ancestors }}
{{ $isCurrentSection := eq $p $currentSection }}
{{/* We currently have a slightly odd structure. */}}
{{ if eq $p site.Home }}
{{ $p = $documentation }}
@ -13,7 +15,7 @@
{{ $isLast := eq $i (sub (len $ancestors) 1) }}
<a
href="{{ $p.RelPermalink }}"
class="truncate text-blue-600 hover:text-blue-500 {{ if $isLast }}
class="truncate text-blue-600 hover:text-blue-500 {{ if $isCurrentSection }}
current-section
{{ end }}"
>{{ $p.LinkTitle }}</a
@ -24,7 +26,11 @@
</li>
{{ end }}
{{ if ne $ $documentation }}
<li class="truncate text-gray-700 dark:text-gray-300">
{{ $isCurrentSection := eq $ $currentSection }}
<li
class="truncate text-gray-700 dark:text-gray-300 {{ if $isCurrentSection }}
current-section
{{ end }}">
{{ $.LinkTitle }}
</li>
{{ end }}