Skip to content

Commit 7f321a9

Browse files
committed
hugo: move sidebar main navigation to partial
Signed-off-by: David Karlsson <[email protected]>
1 parent 9419988 commit 7f321a9

File tree

4 files changed

+43
-38
lines changed

4 files changed

+43
-38
lines changed

hugo_stats.json

+3
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@
354354
"link",
355355
"lntable",
356356
"lntd",
357+
"m-2",
357358
"m-4",
358359
"m-auto",
359360
"macOS",
@@ -393,6 +394,7 @@
393394
"mt-1",
394395
"mt-2",
395396
"mt-20",
397+
"mt-4",
396398
"mx-auto",
397399
"my-0",
398400
"my-2",
@@ -432,6 +434,7 @@
432434
"pr-2",
433435
"prose",
434436
"pt-0",
437+
"pt-4",
435438
"px-1",
436439
"px-2",
437440
"px-3",

layouts/_default/baseof.html

-38
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,6 @@
2222
<span class="icon-svg">{{ partialCached "icon" "arrow_left_alt" "arrow_left_alt" }}</span>
2323
Back
2424
</button>
25-
<!-- Main navigation -->
26-
<div class="py-2 px-4" x-data="{ expanded: false }">
27-
<div class="flex w-full items-center justify-between">
28-
<a class="hover:text-blue-light dark:hover:text-blue-dark" href="{{ .FirstSection.Permalink }}">
29-
{{- with .FirstSection.Params.icon }}
30-
<span class="pr-2 icon-sm icon-svg">
31-
{{- partialCached "icon.html" . . -}}
32-
</span>
33-
{{- end }}
34-
{{- .FirstSection.LinkTitle -}}
35-
</a>
36-
<button @click="expanded = !expanded" class="rounded hover:bg-gray-light-300 hover:dark:bg-gray-dark-300">
37-
<span x-show="! expanded" class="icon-svg">
38-
{{ partialCached "icon" "expand_more" "expand_more" }}
39-
</span>
40-
<span x-cloak x-show="expanded" class="icon-svg">
41-
{{ partialCached "icon" "expand_less" "expand_less" }}
42-
</span>
43-
</button>
44-
</div>
45-
<ul x-cloak x-show="expanded" class="py-4 space-y-4">
46-
{{ range site.Menus.main }}
47-
{{ if ne page.FirstSection .Page }}
48-
<li>
49-
<a class="hover:text-blue-light dark:hover:text-blue-dark" href="{{ .URL }}">
50-
{{- with .Page.Params.icon }}
51-
<span class="pr-2 icon-sm icon-svg">
52-
{{- partialCached "icon.html" . . -}}
53-
</span>
54-
{{- end }}
55-
{{- .Name }}
56-
</a>
57-
</li>
58-
{{ end }}
59-
{{ end }}
60-
</ul>
61-
</div>
62-
<hr class="my-2 text-gray-light-200 dark:text-gray-dark-300" />
6325
<!-- Actual Sidebar Content -->
6426
{{ block "left" . }}
6527
{{ end }}

layouts/partials/sidebar-mainnav.html

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!-- Main navigation for the sidebar -->
2+
<div class="py-2 px-4" x-data="{ expanded: false }">
3+
<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 }}
6+
<span class="pr-2 icon-sm icon-svg">
7+
{{- partialCached "icon.html" . . -}}
8+
</span>
9+
{{- end }}
10+
{{- .FirstSection.LinkTitle -}}
11+
</a>
12+
<button @click="expanded = !expanded" class="rounded hover:bg-gray-light-300 hover:dark:bg-gray-dark-300">
13+
<span x-show="! expanded" class="icon-svg">
14+
{{ partialCached "icon" "expand_more" "expand_more" }}
15+
</span>
16+
<span x-cloak x-show="expanded" class="icon-svg">
17+
{{ partialCached "icon" "expand_less" "expand_less" }}
18+
</span>
19+
</button>
20+
</div>
21+
<ul x-cloak x-show="expanded" class="pt-4 space-y-4">
22+
{{ range site.Menus.main }}
23+
{{ if ne page.FirstSection .Page }}
24+
<li>
25+
<a class="hover:text-blue-light dark:hover:text-blue-dark" href="{{ .URL }}">
26+
{{- with .Page.Params.icon }}
27+
<span class="pr-2 icon-sm icon-svg">
28+
{{- partialCached "icon.html" . . -}}
29+
</span>
30+
{{- end }}
31+
{{- .Name }}
32+
</a>
33+
</li>
34+
{{ end }}
35+
{{ end }}
36+
</ul>
37+
</div>
38+
<hr class="m-2 text-gray-light-200 dark:text-gray-dark-300" />

layouts/partials/sidebar.html

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

0 commit comments

Comments
 (0)