forked from drowl87/hextra_mirror
refactor: split out sidebar elements into partials
This commit is contained in:
parent
24f3178ea8
commit
98d0a3dc73
@ -74,7 +74,7 @@
|
||||
<li class="{{ if $shouldOpen }}open{{ end }}">
|
||||
{{- template "sidebar-item-link" dict "context" . "active" $active "title" .LinkTitle "link" .RelPermalink -}}
|
||||
{{- if and $toc $active -}}
|
||||
{{- template "sidebar-toc" dict "page" . -}}
|
||||
{{- partial "sidebar/toc" . -}}
|
||||
{{- end -}}
|
||||
{{- template "sidebar-tree" dict "context" . "page" $page "pageURL" $pageURL "level" (add $level 1) "toc" $toc -}}
|
||||
</li>
|
||||
@ -89,7 +89,7 @@
|
||||
<li class="flex flex-col gap-1 {{ if $shouldOpen }}open{{ end }}">
|
||||
{{- template "sidebar-item-link" dict "context" . "active" $active "title" $title "link" .RelPermalink -}}
|
||||
{{- if and $toc $active -}}
|
||||
{{ template "sidebar-toc" dict "page" . }}
|
||||
{{ partial "sidebar/toc" . }}
|
||||
{{- end }}
|
||||
{{ template "sidebar-tree" dict "context" . "page" $page "pageURL" $pageURL "level" (add $level 1) "toc" $toc }}
|
||||
</li>
|
||||
@ -100,41 +100,6 @@
|
||||
{{- 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 "partials/sidebar/footer" -}}
|
||||
{{- range site.Menus.sidebar -}}
|
||||
{{- $name := or (T .Identifier) .Name -}}
|
||||
{{ 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 | relLangURL) }}</li>
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "sidebar-item-link" -}}
|
||||
{{- $external := strings.HasPrefix .link "http" -}}
|
||||
{{- $open := .open | default true -}}
|
||||
@ -154,9 +119,3 @@
|
||||
{{ end -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
||||
{{- define "partials/sidebar/collapsible-button" -}}
|
||||
<span class="hextra-sidebar-collapsible-button">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" class="h-[18px] min-w-[18px] rounded-sm p-0.5 hover:bg-gray-800/5 dark:hover:bg-gray-100/5"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" class="origin-center transition-transform rtl:-rotate-180"></path></svg>
|
||||
</span>
|
||||
{{- end -}}
|
||||
|
3
layouts/partials/sidebar/collapsible-button.html
Normal file
3
layouts/partials/sidebar/collapsible-button.html
Normal file
@ -0,0 +1,3 @@
|
||||
<span class="hextra-sidebar-collapsible-button">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" class="h-[18px] min-w-[18px] rounded-sm p-0.5 hover:bg-gray-800/5 dark:hover:bg-gray-100/5"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" class="origin-center transition-transform rtl:-rotate-180"></path></svg>
|
||||
</span>
|
10
layouts/partials/sidebar/footer.html
Normal file
10
layouts/partials/sidebar/footer.html
Normal file
@ -0,0 +1,10 @@
|
||||
{{- range site.Menus.sidebar -}}
|
||||
{{- $name := or (T .Identifier) .Name -}}
|
||||
{{ 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 | relLangURL) }}</li>
|
||||
{{ end }}
|
||||
{{- end -}}
|
19
layouts/partials/sidebar/toc.html
Normal file
19
layouts/partials/sidebar/toc.html
Normal file
@ -0,0 +1,19 @@
|
||||
{{ $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 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 }}
|
Loading…
x
Reference in New Issue
Block a user