feat: highlight current page
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
{{- range .nodes.ByWeight -}}
|
||||
{{- $isCurrent := eq .RelPermalink $.currentPage.RelPermalink -}}
|
||||
{{- if eq $.level 0 -}}
|
||||
<div class="flex flex-col">
|
||||
<a class="flex items-center {{ if .IsSection }}text-on-surface{{ else }}text-on-surface-variant{{ end }} hover:text-primary transition-colors py-1 text-left w-full group" href="{{ .RelPermalink }}">
|
||||
<a class="flex items-center {{ if $isCurrent }}text-primary{{ else if .IsSection }}text-on-surface{{ else }}text-on-surface-variant{{ end }} hover:text-primary transition-colors py-1 text-left w-full group" href="{{ .RelPermalink }}">
|
||||
<span class="material-symbols-outlined text-[16px] mr-1 text-on-surface-variant group-hover:text-primary">{{ if .IsSection }}expand_more{{ else }}chevron_right{{ end }}</span>
|
||||
{{ .LinkTitle }}
|
||||
</a>
|
||||
{{- if .IsSection -}}
|
||||
{{- with .Pages.ByWeight -}}
|
||||
<div class="ml-6 flex flex-col gap-1 text-on-surface-variant text-[13px] tree-item mt-1 mb-2">
|
||||
{{ partial "explorer-tree.html" (dict "nodes" . "level" (add $.level 1)) }}
|
||||
{{ partial "explorer-tree.html" (dict "nodes" . "level" (add $.level 1) "currentPage" $.currentPage) }}
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -16,18 +17,18 @@
|
||||
{{- else -}}
|
||||
{{- if .IsSection -}}
|
||||
<div class="flex flex-col">
|
||||
<a class="flex items-center hover:text-on-surface transition-colors py-0.5" href="{{ .RelPermalink }}">
|
||||
<a class="flex items-center {{ if $isCurrent }}text-primary{{ end }} hover:text-on-surface transition-colors py-0.5" href="{{ .RelPermalink }}">
|
||||
<span class="material-symbols-outlined text-[14px] mr-1 text-on-surface-variant">expand_more</span>
|
||||
{{ .LinkTitle }}
|
||||
</a>
|
||||
{{- with .Pages.ByWeight -}}
|
||||
<div class="ml-5 flex flex-col gap-1 text-on-surface-variant text-[13px] tree-item mt-1 italic">
|
||||
{{ partial "explorer-tree.html" (dict "nodes" . "level" (add $.level 1)) }}
|
||||
{{ partial "explorer-tree.html" (dict "nodes" . "level" (add $.level 1) "currentPage" $.currentPage) }}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- else -}}
|
||||
<a class="hover:text-on-surface transition-colors py-0.5 italic" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
<a class="{{ if $isCurrent }}text-primary{{ end }} hover:text-on-surface transition-colors py-0.5 italic" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<nav class="flex flex-col gap-1 text-[14px]" aria-label="Primary">
|
||||
{{ with site.Sections }}
|
||||
{{ partial "explorer-tree.html" (dict "nodes" . "level" 0) }}
|
||||
{{ partial "explorer-tree.html" (dict "nodes" . "level" 0 "currentPage" $) }}
|
||||
{{ end }}
|
||||
</nav>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user