2023-07-29 17:41:25 +01:00
|
|
|
{{/* Table of Contents */}}
|
|
|
|
{{/* TODO: toc bottom part should be able to hide */}}
|
2023-08-09 22:57:43 +01:00
|
|
|
{{- $toc := .Params.toc | default true -}}
|
2023-08-27 17:32:44 +01:00
|
|
|
{{- $onThisPage := (T "onThisPage") | default "On this page"}}
|
|
|
|
{{- $editThisPage := (T "editThisPage") | default "Edit this page"}}
|
2023-10-01 05:06:28 -04:00
|
|
|
{{- $backToTop := (T "backToTop") | default "Scroll to top" -}}
|
2023-08-09 22:57:43 +01:00
|
|
|
|
2024-02-20 17:59:31 -05:00
|
|
|
<nav class="hextra-toc hx-order-last hx-hidden hx-w-64 hx-shrink-0 xl:hx-block print:hx-hidden hx-px-4" aria-label="table of contents">
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- if $toc }}
|
2024-02-20 17:59:31 -05:00
|
|
|
<div class="hextra-scrollbar hx-sticky hx-top-16 hx-overflow-y-auto hx-pr-4 hx-pt-6 hx-text-sm [hyphens:auto] hx-max-h-[calc(100vh-var(--navbar-height)-env(safe-area-inset-bottom))] ltr:hx--mr-4 rtl:hx--ml-4">
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- with .Fragments.Headings -}}
|
2024-02-20 17:59:31 -05:00
|
|
|
<p class="hx-mb-4 hx-font-semibold hx-tracking-tight">{{ $onThisPage }}</p>
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- range . -}}
|
2023-08-09 22:57:43 +01:00
|
|
|
<ul>
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- with .Headings -}}{{ template "toc-subheading" (dict "headings" . "level" 0) }}{{- end -}}
|
2023-08-09 22:57:43 +01:00
|
|
|
</ul>
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2023-07-29 17:41:25 +01:00
|
|
|
|
2024-02-20 17:59:31 -05:00
|
|
|
{{- $borderClass := "hx-mt-8 hx-border-t hx-bg-white hx-pt-8 hx-shadow-[0_-12px_16px_white] dark:hx-bg-dark dark:hx-shadow-[0_-12px_16px_#111]" -}}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- if not .Fragments.Headings -}}
|
|
|
|
{{- $borderClass = "" -}}
|
|
|
|
{{- end -}}
|
2023-07-29 17:41:25 +01:00
|
|
|
|
2023-08-12 19:53:14 +01:00
|
|
|
{{/* TOC bottom part */}}
|
2024-02-20 17:59:31 -05:00
|
|
|
<div class="{{ $borderClass }} hx-sticky hx-bottom-0 hx-flex hx-flex-col hx-items-start hx-gap-2 hx-pb-8 dark:hx-border-neutral-800 contrast-more:hx-border-t contrast-more:hx-border-neutral-400 contrast-more:hx-shadow-none contrast-more:dark:hx-border-neutral-400">
|
2023-08-23 01:00:36 +01:00
|
|
|
{{- if site.Params.editURL.enable -}}
|
2023-08-12 22:48:41 +01:00
|
|
|
{{- $editURL := site.Params.editURL.base | default "" -}}
|
2024-01-21 10:33:49 +00:00
|
|
|
{{- with .Params.editURL -}}
|
|
|
|
{{/* if `editURL` is set in the front matter */}}
|
|
|
|
{{- $editURL = . -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- with .File -}}
|
|
|
|
{{/* `.FileInfo.Meta.SourceRoot` is a Hugo internal field, e.g. `/path/to/repo/content/en/` */}}
|
|
|
|
{{- $sourceDir := replace (strings.TrimPrefix .FileInfo.Meta.BaseDir .FileInfo.Meta.SourceRoot) "\\" "/" -}}
|
|
|
|
{{- $sourceDir = strings.TrimPrefix "/content" $sourceDir -}}
|
|
|
|
{{- $path := replace .Path "\\" "/" -}}
|
|
|
|
{{- $editURL = urls.JoinPath $editURL $sourceDir $path -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2024-02-20 17:59:31 -05:00
|
|
|
<a class="hx-text-xs hx-font-medium hx-text-gray-500 hover:hx-text-gray-900 dark:hx-text-gray-400 dark:hover:hx-text-gray-100 contrast-more:hx-text-gray-800 contrast-more:dark:hx-text-gray-50" href="{{ $editURL }}" target="_blank" rel="noreferer">{{ $editThisPage }}</a>
|
2023-08-12 19:53:14 +01:00
|
|
|
{{- end -}}
|
2023-10-01 05:06:28 -04:00
|
|
|
{{/* Scroll To Top */}}
|
2024-02-20 17:59:31 -05:00
|
|
|
<button aria-hidden="true" id="backToTop" onClick="scrollUp();" class="hx-transition-all hx-duration-75 hx-opacity-0 hx-text-xs hx-font-medium hx-text-gray-500 hover:hx-text-gray-900 dark:hx-text-gray-400 dark:hover:hx-text-gray-100 contrast-more:hx-text-gray-800 contrast-more:dark:hx-text-gray-50">
|
2023-10-01 05:06:28 -04:00
|
|
|
<span>
|
|
|
|
{{- $backToTop -}}
|
|
|
|
</span>
|
2024-02-20 17:59:31 -05:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="hx-inline hx-ml-1 hx-h-3.5 hx-w-3.5 hx-border hx-rounded-full hx-border-gray-500 hover:hx-border-gray-900 dark:hx-border-gray-400 dark:hover:hx-border-gray-100 contrast-more:hx-border-gray-800 contrast-more:dark:hx-border-gray-50">
|
2023-10-01 05:06:28 -04:00
|
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
|
|
|
|
</svg>
|
|
|
|
</button>
|
2023-08-09 22:57:43 +01:00
|
|
|
</div>
|
2023-07-29 17:41:25 +01:00
|
|
|
</div>
|
2023-08-14 21:56:26 +01:00
|
|
|
{{ end -}}
|
2023-08-09 22:57:43 +01:00
|
|
|
</nav>
|
2023-07-29 17:41:25 +01:00
|
|
|
|
2023-08-09 22:57:43 +01:00
|
|
|
{{/* TOC subheadings component. This is a recursive component that renders a list of headings. */}}
|
|
|
|
{{- define "toc-subheading" -}}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- $headings := .headings -}}
|
|
|
|
{{- $level := .level -}}
|
|
|
|
{{- if ge $level 6 -}}
|
2023-07-29 17:41:25 +01:00
|
|
|
{{ return }}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- end -}}
|
2023-07-29 17:41:25 +01:00
|
|
|
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- $padding := (mul $level 4) -}}
|
2024-02-20 17:59:31 -05:00
|
|
|
{{- $class := cond (eq $level 0) "hx-font-semibold" (printf "ltr:hx-pl-%d rtl:hx-pr-%d" $padding $padding) -}}
|
2023-07-29 17:41:25 +01:00
|
|
|
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- range $headings }}
|
|
|
|
{{- if .Title }}
|
2024-02-20 17:59:31 -05:00
|
|
|
<li class="hx-my-2 hx-scroll-my-6 hx-scroll-py-6">
|
|
|
|
<a class="{{ $class }} hx-inline-block hx-text-gray-500 hover:hx-text-gray-900 dark:hx-text-gray-400 dark:hover:hx-text-gray-300 contrast-more:hx-text-gray-900 contrast-more:hx-underline contrast-more:dark:hx-text-gray-50 hx-w-full hx-break-words" href="#{{ anchorize .ID }}">
|
2023-11-05 05:26:00 -05:00
|
|
|
{{- .Title | safeHTML | plainify | htmlUnescape }}
|
2023-07-29 17:41:25 +01:00
|
|
|
</a>
|
|
|
|
</li>
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- end -}}
|
|
|
|
{{- with .Headings -}}
|
2023-08-09 22:57:43 +01:00
|
|
|
{{ template "toc-subheading" (dict "headings" . "level" (add $level 1)) }}
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- end -}}
|
2023-07-29 17:41:25 +01:00
|
|
|
|
2023-08-14 21:56:26 +01:00
|
|
|
{{- end -}}
|
2023-07-29 17:41:25 +01:00
|
|
|
{{- end -}}
|