|
32 | 32 | {{- end }} |
33 | 33 | {{- range .Params.sidebar.groups }} |
34 | 34 | <!-- Main titles --> |
35 | | - <li class="navbar-group-font-title mt-2 px-2 py-2 pt-5 pb-2"> |
36 | | - {{ . }} |
37 | | - </li> |
38 | | - {{- range where $pages "Params.sidebar.group" . }} |
39 | | - {{- if .IsSection }} |
40 | | - {{- template "renderList" . }} |
41 | | - {{- else }} |
42 | | - {{- template "renderSingle" . }} |
| 35 | + <div class="navbar-group"> |
| 36 | + <li class="navbar-group-font-title"> |
| 37 | + {{ . }} |
| 38 | + </li> |
| 39 | + {{- range where $pages "Params.sidebar.group" . }} |
| 40 | + {{- if .IsSection }} |
| 41 | + {{- template "renderList" . }} |
| 42 | + {{- else }} |
| 43 | + {{- template "renderSingle" . }} |
| 44 | + {{- end }} |
43 | 45 | {{- end }} |
44 | | - {{- end }} |
| 46 | + </div> |
45 | 47 | {{- end }} |
| 48 | + |
46 | 49 | {{ end }} |
47 | 50 |
|
48 | 51 | {{/* Recursive template for sidebar items */}} |
49 | 52 | {{ define "renderList" }} |
50 | 53 | {{ $isCurrent := eq page . }} |
51 | 54 | {{ $expanded := or $isCurrent (page.IsDescendant .) }} |
52 | | - <li x-data="{ expanded: {{ $expanded }} }"> |
| 55 | + <li class="" x-data="{ expanded: {{ $expanded }} }"> |
53 | 56 | <div |
54 | | - class="justify-between{{ if $isCurrent }} |
55 | | - bg-gray-100 dark:bg-gray-900 |
56 | | - {{ end }} flex w-full items-center rounded-sm px-4" |
| 57 | + class="{{ if $isCurrent }} |
| 58 | + navbar-entry-background-current |
| 59 | + {{ end }} flex w-full items-center justify-between rounded-sm" |
57 | 60 | > |
58 | | - <div class="w-full truncate py-1"> |
| 61 | + <div class="navbar-entry-margin w-full truncate"> |
59 | 62 | {{- if .Permalink }} |
60 | 63 | {{/* If the link is not empty, use it */}} |
| 64 | + <!-- Sections that have children and linking to a page --> |
61 | 65 | <a |
62 | 66 | {{ if $isCurrent }} |
63 | 67 | aria-current="page" id="sidebar-current-page" |
|
69 | 73 | </a> |
70 | 74 | {{- else }} |
71 | 75 | {{/* Otherwise, just expand the section */}} |
| 76 | + <!-- Sections that have children and do not link to a page --> |
72 | 77 | <button |
73 | 78 | @click="expanded = !expanded" |
74 | 79 | class="hover:text-blue w-full text-left select-none hover:dark:text-blue-400" |
|
77 | 82 | </button> |
78 | 83 | {{- end }} |
79 | 84 | </div> |
| 85 | + <!-- Expand group button --> |
80 | 86 | <button |
81 | 87 | @click="expanded = !expanded" |
82 | | - class="rounded-sm hover:bg-gray-300 hover:dark:bg-gray-300" |
| 88 | + class="rounded-sm hover:bg-gray-200 hover:dark:bg-gray-800" |
83 | 89 | > |
84 | 90 | <span |
85 | 91 | :class="{ 'hidden' : expanded }" |
|
106 | 112 |
|
107 | 113 | {{ define "renderSingle" }} |
108 | 114 | {{- if .Params.sidebar.goto }} |
109 | | - <li class="hover:text-blue px-4 hover:dark:text-blue-400"> |
| 115 | + <li class="navbar-entry-margin hover:text-blue hover:dark:text-blue-400"> |
110 | 116 | <a |
111 | | - class="block w-full truncate py-2" |
| 117 | + class="block w-full truncate" |
112 | 118 | href="{{ .Params.sidebar.goto }}" |
113 | 119 | title="{{ .LinkTitle }}" |
114 | 120 | > |
|
118 | 124 | {{- else }} |
119 | 125 | {{ $isCurrent := eq page . }} |
120 | 126 | <li |
121 | | - class="hover:text-blue {{ if $isCurrent }} |
122 | | - bg-gray-100 dark:bg-gray-900 |
123 | | - {{ end }} rounded-sm px-4 hover:dark:text-blue-400" |
| 127 | + class="navbar-entry-margin hover:text-blue {{ if $isCurrent }} |
| 128 | + navbar-entry-background-current |
| 129 | + {{ end }} rounded-sm hover:dark:text-blue-400" |
124 | 130 | > |
125 | 131 | <a |
126 | 132 | {{ if $isCurrent }} |
127 | 133 | aria-current="page" id="sidebar-current-page" |
128 | 134 | {{ end }} |
129 | | - class="block w-full truncate py-2" |
| 135 | + class="block w-full truncate" |
130 | 136 | href="{{ .Permalink }}" |
131 | 137 | title="{{ .LinkTitle }}" |
132 | 138 | > |
|
139 | 145 | {{ define "renderTitle" }} |
140 | 146 | {{ .LinkTitle }} |
141 | 147 | {{- with .Params.sidebar.badge }} |
142 | | - <span |
143 | | - >{{- partial "components/badge.html" (dict "color" .color "content" .text) }}</span |
144 | | - > |
| 148 | + <span> |
| 149 | + {{- partial "components/badge.html" (dict "color" .color "content" .text) }} |
| 150 | + </span> |
145 | 151 | {{- end }} |
146 | 152 | {{ end }} |
0 commit comments