hugo: refactor sidebar templates

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-09-17 10:11:09 +02:00
parent 7f321a9197
commit 5eb0381ef1
17 changed files with 20 additions and 40 deletions

View File

@ -394,7 +394,6 @@
"mt-1", "mt-1",
"mt-2", "mt-2",
"mt-20", "mt-20",
"mt-4",
"mx-auto", "mx-auto",
"my-0", "my-0",
"my-2", "my-2",

View File

@ -24,6 +24,8 @@
</button> </button>
<!-- Actual Sidebar Content --> <!-- Actual Sidebar Content -->
{{ block "left" . }} {{ block "left" . }}
{{ partial "sidebar/mainnav.html" . }}
{{ partial "sidebar/sections.html" . }}
{{ end }} {{ end }}
</div> </div>
</div> </div>

View File

@ -1,7 +1,3 @@
{{ define "left" }}
{{ partial "sidebar.html" . }}
{{ end }}
{{ define "main" }} {{ define "main" }}
{{ $data := "" }} {{ $data := "" }}
{{ if .Params.datafolder }} {{ if .Params.datafolder }}

View File

@ -1,5 +1,5 @@
{{ define "left" }} {{ define "left" }}
{{ partial "sidebar.html" . }} {{ partial "sidebar/mainnav.html" . }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}

View File

@ -1,7 +1,3 @@
{{ define "left" }}
{{ partial "sidebar.html" . }}
{{ end }}
{{ define "main" }} {{ define "main" }}
{{ partial "content-default.html" . }} {{ partial "content-default.html" . }}
{{ end }} {{ end }}

View File

@ -1,5 +1,5 @@
{{ define "left" }} {{ define "left" }}
{{ partial "sidebar.html" . }} {{ partial "sidebar/mainnav.html" . }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}

View File

@ -1,7 +1,3 @@
{{ define "left" }}
{{ partial "sidebar.html" . }}
{{ end }}
{{ define "main" }} {{ define "main" }}
{{ partial "breadcrumbs.html" . }} {{ partial "breadcrumbs.html" . }}
<article class="prose max-w-none dark:prose-invert"> <article class="prose max-w-none dark:prose-invert">

View File

@ -1,7 +1,3 @@
{{ define "left" }}
{{ partial "sidebar.html" . }}
{{ end }}
{{ define "main" }} {{ define "main" }}
{{ partial "content-default.html" . }} {{ partial "content-default.html" . }}
{{ end }} {{ end }}

View File

@ -1,7 +1,3 @@
{{ define "left" }}
{{ partial "sidebar.html" . }}
{{ end }}
{{ define "main" }} {{ define "main" }}
<article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert"> <article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert">
{{ partial "breadcrumbs.html" . }} {{ partial "breadcrumbs.html" . }}

View File

@ -1,7 +1,3 @@
{{ define "left" }}
{{- partial "sidebar.html" . }}
{{ end }}
{{ define "main" }} {{ define "main" }}
<article class="prose max-w-none dark:prose-invert"> <article class="prose max-w-none dark:prose-invert">
{{ partial "breadcrumbs.html" . }} {{ partial "breadcrumbs.html" . }}

View File

@ -12,7 +12,3 @@
{{ partial "post-links.html" (where .CurrentSection.Pages "Permalink" "ne" page.Permalink) }} {{ partial "post-links.html" (where .CurrentSection.Pages "Permalink" "ne" page.Permalink) }}
</article> </article>
{{ end }} {{ end }}
{{ define "left" }}
{{- partial "sidebar.html" . }}
{{ end }}

View File

@ -1,13 +1,20 @@
<!-- Main navigation for the sidebar --> <!-- Main navigation for the sidebar -->
<div class="py-2 px-4" x-data="{ expanded: false }"> <div class="py-2 px-4" x-data="{ expanded: false }">
<div class="flex w-full items-center justify-between"> <div class="flex w-full items-center justify-between">
<a class="hover:text-blue-light dark:hover:text-blue-dark" href="{{ .FirstSection.Permalink }}"> <!-- Current section: use menu, fall back to current page -->
{{- with .FirstSection.Params.icon }} {{- $curr := page }}
{{- range site.Menus.main }}
{{- if .Page.IsAncestor page }}
{{- $curr = .Page }}
{{- end }}
{{- end }}
<a class="hover:text-blue-light dark:hover:text-blue-dark" href="{{ $curr.Permalink }}">
{{- with $curr.Params.icon }}
<span class="pr-2 icon-sm icon-svg"> <span class="pr-2 icon-sm icon-svg">
{{- partialCached "icon.html" . . -}} {{- partialCached "icon.html" . . -}}
</span> </span>
{{- end }} {{- end }}
{{- .FirstSection.LinkTitle -}} {{- $curr.LinkTitle -}}
</a> </a>
<button @click="expanded = !expanded" class="rounded hover:bg-gray-light-300 hover:dark:bg-gray-dark-300"> <button @click="expanded = !expanded" class="rounded hover:bg-gray-light-300 hover:dark:bg-gray-dark-300">
<span x-show="! expanded" class="icon-svg"> <span x-show="! expanded" class="icon-svg">

View File

@ -1,6 +1,4 @@
<!-- section tree --> <!-- section tree -->
{{ partial "sidebar-mainnav.html" . }}
<nav class="md:text-sm flex flex-col"> <nav class="md:text-sm flex flex-col">
<div <div
class="block py-4 md:hidden text-gray-light dark:text-gray-dark">This section</div> class="block py-4 md:hidden text-gray-light dark:text-gray-dark">This section</div>

View File

@ -1,5 +1,6 @@
{{ define "left" }} {{ define "left" }}
{{ partial "sidebar.html" . }} {{ partial "sidebar/mainnav.html" . }}
{{ partial "sidebar/sections.html" . }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}

View File

@ -1,5 +1,6 @@
{{ define "left" }} {{ define "left" }}
{{ partial "sidebar-tags.html" . }} {{ partial "sidebar/mainnav.html" . }}
{{ partial "sidebar/tags.html" . }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}

View File

@ -1,5 +1,5 @@
{{ define "left" }} {{ define "left" }}
{{ partial "sidebar-tags.html" . }} {{ partial "sidebar/tags.html" . }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}