2023-08-07 23:48:07 +01:00
|
|
|
{{ $context := .context }}
|
|
|
|
{{ $disableSidebar := .disableSidebar | default false }}
|
2023-08-09 22:57:43 +01:00
|
|
|
{{ $sidebarClass := cond $disableSidebar "md:hidden xl:block" "md:sticky" }}
|
2023-08-07 23:48:07 +01:00
|
|
|
|
|
|
|
{{ $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection }}
|
|
|
|
{{ $navPages := union $navRoot.RegularPages $navRoot.Sections }}
|
|
|
|
{{ $pageURL := $context.RelPermalink }}
|
|
|
|
|
|
|
|
|
2023-08-09 22:57:43 +01:00
|
|
|
<aside class="sidebar-container flex flex-col print:hidden md:top-16 md:shrink-0 md:w-64 md:self-start max-md:[transform:translate3d(0,-100%,0)] {{ $sidebarClass }}">
|
2023-08-06 15:23:37 +01:00
|
|
|
<!-- Search bar on small screen -->
|
|
|
|
<div class="px-4 pt-4 md:hidden">
|
|
|
|
{{ partial "search.html" }}
|
|
|
|
</div>
|
|
|
|
<div class="overflow-y-auto overflow-x-hidden p-4 grow md:h-[calc(100vh-var(--navbar-height)-var(--menu-height))]">
|
|
|
|
<ul class="flex flex-col gap-1 md:hidden">
|
2023-08-07 23:48:07 +01:00
|
|
|
<!-- Nav -->
|
|
|
|
{{- range site.Menus.main -}}
|
|
|
|
{{- if and .URL (and (ne .Params.type "search") (not .Params.icon)) -}}
|
2023-08-06 15:23:37 +01:00
|
|
|
<li>{{ template "sidebar-item-link" dict "active" false "title" .Name "link" .URL }}</li>
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2023-08-07 23:48:07 +01:00
|
|
|
{{ template "sidebar-separator" }}
|
|
|
|
{{ template "sidebar-main" (dict "pages" $navPages "pageURL" $pageURL "toc" true) }}
|
2023-08-06 15:23:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
<!-- Sidebar footer -->
|
2023-08-07 23:48:07 +01:00
|
|
|
{{ with site.Params.sidebar.footer -}}
|
|
|
|
{{ template "sidebar-separator" }}
|
|
|
|
{{ template "sidebar-footer" }}
|
|
|
|
{{ end }}
|
2023-08-06 15:23:37 +01:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- Sidebar on large screen -->
|
2023-08-07 23:48:07 +01:00
|
|
|
{{ if $disableSidebar -}}
|
|
|
|
<div class="max-xl:hidden h-0 w-64 shrink-0"></div>
|
|
|
|
{{ .context.Scratch.Set "enableFooterSwitches" true }}
|
|
|
|
{{ else }}
|
|
|
|
<ul class="flex flex-col gap-1 max-md:hidden">
|
|
|
|
{{ template "sidebar-main" (dict "pages" $navPages "pageURL" $pageURL) }}
|
|
|
|
{{ template "sidebar-footer" }}
|
|
|
|
</ul>
|
|
|
|
{{ end }}
|
2023-07-27 00:05:47 +01:00
|
|
|
</div>
|
2023-08-07 23:48:07 +01:00
|
|
|
{{/* Hide theme switch when sidebar is disabled */}}
|
|
|
|
{{ template "theme-switch" (dict "class" (cond $disableSidebar "md:hidden" "")) }}
|
2023-08-06 15:23:37 +01:00
|
|
|
</aside>
|
|
|
|
|
2023-08-07 23:48:07 +01:00
|
|
|
{{- define "sidebar-main" -}}
|
|
|
|
{{ $pages := .pages }}
|
|
|
|
{{ $toc := .toc | default false }}
|
|
|
|
{{ $pageURL := .pageURL }}
|
|
|
|
|
|
|
|
{{- with $pages -}}
|
|
|
|
{{- range .ByWeight -}}
|
|
|
|
{{ template "sidebar-item" (dict "item" . "pageURL" $pageURL "toc" $toc) }}
|
|
|
|
{{ template "sidebar-tree" (dict "context" . "level" 1 "pageURL" $pageURL "toc" $toc) }}
|
|
|
|
{{- end -}}
|
|
|
|
{{ end }}
|
|
|
|
{{- end -}}
|
|
|
|
|
2023-08-06 15:23:37 +01:00
|
|
|
{{- define "sidebar-footer" -}}
|
|
|
|
{{- range site.Menus.sidebar -}}
|
|
|
|
{{ if eq .Params.type "separator" }}
|
|
|
|
<li class="[word-break:break-word] mt-5 mb-2 px-2 py-1.5 text-sm font-semibold text-gray-900 first:mt-0 dark:text-gray-100">
|
|
|
|
<span class="cursor-default">{{ .Name }}</span>
|
|
|
|
</li>
|
|
|
|
{{ else }}
|
|
|
|
<li>{{ template "sidebar-item-link" dict "active" false "title" .Name "link" .URL }}</li>
|
|
|
|
{{ end }}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "sidebar-tree" -}}
|
|
|
|
{{ $pageURL := .pageURL }}
|
|
|
|
{{ $level := .level }}
|
|
|
|
{{ $toc := .toc | default false }}
|
|
|
|
|
|
|
|
{{ if ge $level 4 }}
|
|
|
|
{{ return }}
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ $items := union .context.RegularPages .context.Sections }}
|
|
|
|
{{ with $items }}
|
|
|
|
<div class="pt-1 ltr:pr-0">
|
|
|
|
<ul class='relative flex flex-col gap-1 before:absolute before:inset-y-1 before:w-px before:bg-gray-200 before:content-[""] ltr:ml-3 ltr:pl-3 ltr:before:left-0 rtl:mr-3 rtl:pr-3 rtl:before:right-0 dark:before:bg-neutral-800'>
|
|
|
|
{{ range $items.ByWeight }}
|
|
|
|
{{ $active := eq $pageURL .RelPermalink }}
|
|
|
|
{{ $title := .LinkTitle | default .File.BaseFileName }}
|
|
|
|
<li class="flex flex-col gap-1">
|
|
|
|
{{ template "sidebar-item-link" dict "active" $active "title" $title "link" .RelPermalink }}
|
|
|
|
{{ if and $toc $active }}
|
|
|
|
{{ template "sidebar-toc" dict "page" . }}
|
|
|
|
{{ end }}
|
|
|
|
</li>
|
|
|
|
{{ template "sidebar-tree" dict "context" . "pageURL" $pageURL "level" (add $level 1) }}
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
{{ end }}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "sidebar-toc" -}}
|
|
|
|
{{ $page := .page }}
|
|
|
|
{{ with $page.Fragments.Headings }}
|
|
|
|
<ul class='flex flex-col gap-1 relative before:absolute before:inset-y-1 before:w-px before:bg-gray-200 before:content-[""] dark:before:bg-neutral-800 ltr:pl-3 ltr:before:left-0 rtl:pr-3 rtl:before:right-0 ltr:ml-3 rtl:mr-3'>
|
|
|
|
{{ range . }}
|
|
|
|
{{ with .Headings }}
|
|
|
|
{{ range . }}
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="#{{ anchorize .ID }}"
|
|
|
|
class="flex rounded px-2 py-1.5 text-sm transition-colors [word-break:break-word] cursor-pointer [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] contrast-more:border flex gap-2 before:opacity-25 before:content-['#'] text-gray-500 hover:bg-gray-100 hover:text-gray-900 dark:text-neutral-400 dark:hover:bg-primary-100/5 dark:hover:text-gray-50 contrast-more:text-gray-900 contrast-more:dark:text-gray-50 contrast-more:border-transparent contrast-more:hover:border-gray-900 contrast-more:dark:hover:border-gray-50"
|
|
|
|
>
|
|
|
|
{{- .Title -}}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
{{ end }}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "sidebar-item" }}
|
|
|
|
{{- $active := eq .pageURL .item.RelPermalink -}}
|
|
|
|
{{- $title := .item.LinkTitle | default .item.File.BaseFileName -}}
|
|
|
|
{{- $link := .item.RelPermalink -}}
|
2023-08-07 23:48:07 +01:00
|
|
|
{{- $toc := .toc | default false -}}
|
2023-08-06 15:23:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
<li class="open">
|
|
|
|
{{ template "sidebar-item-link" dict "active" $active "title" $title "link" $link }}
|
2023-08-07 23:48:07 +01:00
|
|
|
{{ if and $toc $active }}
|
|
|
|
{{ template "sidebar-toc" dict "page" .item }}
|
|
|
|
{{ end }}
|
2023-08-06 15:23:37 +01:00
|
|
|
</li>
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "sidebar-item-link" -}}
|
|
|
|
{{ $external := strings.HasPrefix .link "http" }}
|
|
|
|
<a
|
|
|
|
class="flex cursor-pointer rounded px-2 py-1.5 text-sm transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] [word-break:break-word]
|
|
|
|
{{- if .active }}
|
|
|
|
bg-primary-100 font-semibold text-primary-800 contrast-more:border contrast-more:border-primary-500 dark:bg-primary-400/10 dark:text-primary-600 contrast-more:dark:border-primary-500
|
|
|
|
{{- else }}
|
|
|
|
text-gray-500 hover:bg-gray-100 hover:text-gray-900 contrast-more:border contrast-more:border-transparent contrast-more:text-gray-900 contrast-more:hover:border-gray-900 dark:text-neutral-400 dark:hover:bg-primary-100/5 dark:hover:text-gray-50 contrast-more:dark:text-gray-50 contrast-more:dark:hover:border-gray-50
|
|
|
|
{{- end -}}"
|
|
|
|
href="{{ .link }}"
|
|
|
|
{{ if $external }}target="_blank" rel="noreferer"{{ end }}
|
|
|
|
>
|
|
|
|
{{- .title -}}
|
|
|
|
</a>
|
|
|
|
{{- end -}}
|
|
|
|
|
2023-08-07 23:48:07 +01:00
|
|
|
{{- define "sidebar-separator" -}}
|
|
|
|
<div class="mt-4 border-t py-4 dark:border-neutral-800 contrast-more:border-neutral-400 dark:contrast-more:border-neutral-400" />
|
|
|
|
{{- end -}}
|
|
|
|
|
2023-08-06 15:23:37 +01:00
|
|
|
{{- define "theme-switch" -}}
|
2023-08-07 23:48:07 +01:00
|
|
|
{{- $class := .class -}}
|
|
|
|
<div class="{{ $class }} sticky bottom-0 bg-white dark:bg-dark mx-4 py-4 shadow-[0_-12px_16px_#fff] flex items-center gap-2 dark:border-neutral-800 dark:shadow-[0_-12px_16px_#111] contrast-more:border-neutral-400 contrast-more:shadow-none contrast-more:dark:shadow-none border-t" data-toggle-animation="show">
|
2023-07-30 21:50:41 +01:00
|
|
|
<div class="grow flex flex-col">
|
2023-08-07 23:48:07 +01:00
|
|
|
{{ partial "theme-toggle" }}
|
2023-07-30 21:50:41 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-06 15:23:37 +01:00
|
|
|
{{- end -}}
|