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