Skip to content

Commit 5eb0381

Browse files
committed
hugo: refactor sidebar templates
Signed-off-by: David Karlsson <[email protected]>
1 parent 7f321a9 commit 5eb0381

17 files changed

+20
-40
lines changed

hugo_stats.json

-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@
394394
"mt-1",
395395
"mt-2",
396396
"mt-20",
397-
"mt-4",
398397
"mx-auto",
399398
"my-0",
400399
"my-2",

layouts/_default/baseof.html

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
</button>
2525
<!-- Actual Sidebar Content -->
2626
{{ block "left" . }}
27+
{{ partial "sidebar/mainnav.html" . }}
28+
{{ partial "sidebar/sections.html" . }}
2729
{{ end }}
2830
</div>
2931
</div>

layouts/_default/cli.html

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
3-
{{ end }}
4-
51
{{ define "main" }}
62
{{ $data := "" }}
73
{{ if .Params.datafolder }}

layouts/_default/glossary.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
2+
{{ partial "sidebar/mainnav.html" . }}
33
{{ end }}
44

55
{{ define "main" }}

layouts/_default/list.html

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
3-
{{ end }}
4-
51
{{ define "main" }}
62
{{ partial "content-default.html" . }}
73
{{ end }}

layouts/_default/search.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
2+
{{ partial "sidebar/mainnav.html" . }}
33
{{ end }}
44

55
{{ define "main" }}

layouts/_default/series.html

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
3-
{{ end }}
4-
51
{{ define "main" }}
62
{{ partial "breadcrumbs.html" . }}
73
<article class="prose max-w-none dark:prose-invert">

layouts/_default/single.html

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
3-
{{ end }}
4-
51
{{ define "main" }}
62
{{ partial "content-default.html" . }}
73
{{ end }}

layouts/_default/wide.html

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
3-
{{ end }}
4-
51
{{ define "main" }}
6-
<article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert">
2+
<article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert">
73
{{ partial "breadcrumbs.html" . }}
84
<h1 data-pagefind-weight="10" class="scroll-mt-36">{{ .Title }}</h1>
95
{{ if eq .CurrentSection.Layout "series" }}

layouts/learning-paths/list.html

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{{ define "left" }}
2-
{{- partial "sidebar.html" . }}
3-
{{ end }}
4-
51
{{ define "main" }}
62
<article class="prose max-w-none dark:prose-invert">
73
{{ partial "breadcrumbs.html" . }}

layouts/learning-paths/single.html

-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,3 @@ <h1 class="scroll-mt-36">{{ .Title }}</h1>
1212
{{ partial "post-links.html" (where .CurrentSection.Pages "Permalink" "ne" page.Permalink) }}
1313
</article>
1414
{{ end }}
15-
16-
{{ define "left" }}
17-
{{- partial "sidebar.html" . }}
18-
{{ end }}

layouts/partials/sidebar-mainnav.html renamed to layouts/partials/sidebar/mainnav.html

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<!-- Main navigation for the sidebar -->
22
<div class="py-2 px-4" x-data="{ expanded: false }">
33
<div class="flex w-full items-center justify-between">
4-
<a class="hover:text-blue-light dark:hover:text-blue-dark" href="{{ .FirstSection.Permalink }}">
5-
{{- with .FirstSection.Params.icon }}
4+
<!-- Current section: use menu, fall back to current page -->
5+
{{- $curr := page }}
6+
{{- range site.Menus.main }}
7+
{{- if .Page.IsAncestor page }}
8+
{{- $curr = .Page }}
9+
{{- end }}
10+
{{- end }}
11+
<a class="hover:text-blue-light dark:hover:text-blue-dark" href="{{ $curr.Permalink }}">
12+
{{- with $curr.Params.icon }}
613
<span class="pr-2 icon-sm icon-svg">
714
{{- partialCached "icon.html" . . -}}
815
</span>
916
{{- end }}
10-
{{- .FirstSection.LinkTitle -}}
17+
{{- $curr.LinkTitle -}}
1118
</a>
1219
<button @click="expanded = !expanded" class="rounded hover:bg-gray-light-300 hover:dark:bg-gray-dark-300">
1320
<span x-show="! expanded" class="icon-svg">

layouts/partials/sidebar.html renamed to layouts/partials/sidebar/sections.html

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<!-- section tree -->
2-
{{ partial "sidebar-mainnav.html" . }}
3-
42
<nav class="md:text-sm flex flex-col">
53
<div
64
class="block py-4 md:hidden text-gray-light dark:text-gray-dark">This section</div>

layouts/samples/single.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{ define "left" }}
2-
{{ partial "sidebar.html" . }}
2+
{{ partial "sidebar/mainnav.html" . }}
3+
{{ partial "sidebar/sections.html" . }}
34
{{ end }}
45

56
{{ define "main" }}

layouts/tag/taxonomy.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{ define "left" }}
2-
{{ partial "sidebar-tags.html" . }}
2+
{{ partial "sidebar/mainnav.html" . }}
3+
{{ partial "sidebar/tags.html" . }}
34
{{ end }}
45

56
{{ define "main" }}

layouts/tag/term.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "left" }}
2-
{{ partial "sidebar-tags.html" . }}
2+
{{ partial "sidebar/tags.html" . }}
33
{{ end }}
44

55
{{ define "main" }}

0 commit comments

Comments
 (0)