mirror of
https://github.com/imfing/hextra.git
synced 2025-06-20 09:31:23 -04:00
refactor: use "sidebar-tree" for entire rendering
chore: update example site content chore: add configuration for footer chore: allow disable footer completely chore: navbar highlights if contains current page chore: styling update for partial templates chore: update steps to use markdown delimiter
This commit is contained in:
@ -5,23 +5,21 @@
|
||||
|
||||
|
||||
<nav class="hextra-toc order-last hidden w-64 shrink-0 xl:block print:hidden px-4" aria-label="table of contents">
|
||||
{{ if $toc }}
|
||||
{{- if $toc }}
|
||||
<div class="sticky top-16 overflow-y-auto pr-4 pt-6 text-sm [hyphens:auto] max-h-[calc(100vh-4rem-env(safe-area-inset-bottom))] ltr:-mr-4 rtl:-ml-4">
|
||||
{{ with .Fragments.Headings }}
|
||||
{{- with .Fragments.Headings -}}
|
||||
<p class="mb-4 font-semibold tracking-tight">{{ i18n "article.on_this_page" }}</p>
|
||||
{{ range . }}
|
||||
{{- range . -}}
|
||||
<ul>
|
||||
{{ with .Headings }}
|
||||
{{ template "toc-subheading" (dict "headings" . "level" 0) }}
|
||||
{{ end }}
|
||||
{{- with .Headings -}}{{ template "toc-subheading" (dict "headings" . "level" 0) }}{{- end -}}
|
||||
</ul>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ $borderClass := "mt-8 border-t bg-white pt-8 shadow-[0_-12px_16px_white] dark:bg-dark dark:shadow-[0_-12px_16px_#111]" }}
|
||||
{{ if not .Fragments.Headings }}
|
||||
{{ $borderClass = "" }}
|
||||
{{ end }}
|
||||
{{- $borderClass := "mt-8 border-t bg-white pt-8 shadow-[0_-12px_16px_white] dark:bg-dark dark:shadow-[0_-12px_16px_#111]" -}}
|
||||
{{- if not .Fragments.Headings -}}
|
||||
{{- $borderClass = "" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* TOC bottom part */}}
|
||||
<div class="{{ $borderClass }} sticky bottom-0 flex flex-col items-start gap-2 pb-8 dark:border-neutral-800 contrast-more:border-t contrast-more:border-neutral-400 contrast-more:shadow-none contrast-more:dark:border-neutral-400">
|
||||
@ -33,31 +31,31 @@
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
</nav>
|
||||
|
||||
{{/* TOC subheadings component. This is a recursive component that renders a list of headings. */}}
|
||||
{{- define "toc-subheading" -}}
|
||||
{{ $headings := .headings }}
|
||||
{{ $level := .level }}
|
||||
{{ if ge $level 6 }}
|
||||
{{- $headings := .headings -}}
|
||||
{{- $level := .level -}}
|
||||
{{- if ge $level 6 -}}
|
||||
{{ return }}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
|
||||
{{ $padding := (mul $level 4) }}
|
||||
{{ $class := cond (eq $level 0) "font-semibold" (printf "ltr:pl-%d rtl:pr-%d" $padding $padding) }}
|
||||
{{- $padding := (mul $level 4) -}}
|
||||
{{- $class := cond (eq $level 0) "font-semibold" (printf "ltr:pl-%d rtl:pr-%d" $padding $padding) -}}
|
||||
|
||||
{{ range $headings }}
|
||||
{{ if .Title }}
|
||||
{{- range $headings }}
|
||||
{{- if .Title }}
|
||||
<li class="my-2 scroll-my-6 scroll-py-6">
|
||||
<a class="{{ $class }} inline-block text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-300 contrast-more:text-gray-900 contrast-more:underline contrast-more:dark:text-gray-50 w-full break-words" href="#{{ anchorize .ID }}">
|
||||
{{ .Title }}
|
||||
{{- .Title -}}
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ with .Headings }}
|
||||
{{- end -}}
|
||||
{{- with .Headings -}}
|
||||
{{ template "toc-subheading" (dict "headings" . "level" (add $level 1)) }}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
Reference in New Issue
Block a user