Skip to content

Commit d4f28bb

Browse files
authored
Merge pull request #1702 from gethinode/templatev2
Templatev2
2 parents 20d2dca + 5123d1e commit d4f28bb

File tree

8 files changed

+242
-87
lines changed

8 files changed

+242
-87
lines changed

data/structures/example.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ arguments:
1414
show_markup:
1515
type: bool
1616
optional: true
17-
default: true
1817
comment: Indicates if the markup should be output in the HTML.
1918
deprecated: v1.0.0
2019
alternative: show-markup
2120
show_preview:
2221
type: bool
2322
optional: true
24-
default: true
2523
comment: Indicates if the preview should be output in the HTML.
2624
deprecated: v1.0.0
2725
alternative: show-preview

data/structures/live-pages.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,19 @@ arguments:
7373
optional: true
7474
default: true
7575
comment: >-
76-
If set, returns the page collection in descending order.
76+
If set, returns the page collection in descending order.
77+
group-by:
78+
type: select
79+
optional: true
80+
comment:
81+
If set, groups the results by the specified field. Currently only supports
82+
grouping by section.
83+
values:
84+
- section
85+
release: v2.0.0
86+
include-list:
87+
type: bool
88+
optional: true
89+
comment:
90+
If set, includes list pages in the results.
91+
release: v2.0.0

data/structures/sidebar.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,22 @@ arguments:
2222
comment: >-
2323
Version of the sidebar navigation, used to define the base URL of
2424
generated links, together with the page's section.
25+
auto-generate:
26+
type: bool
27+
optional: true
28+
default: false
29+
comment: >-
30+
Flag to auto-generate the content of the sidebar. When set, the sidebar
31+
lists all pages of the current section. Use `nested`, `reverse`, and
32+
`sort` arguments to refine the behavior.
33+
release: v2.0.0
34+
nested:
35+
default: true
36+
release: v2.0.0
37+
reverse:
38+
default: false
39+
release: v2.0.0
40+
sort:
41+
optional: true
42+
default: weight
43+
release: v2.0.0

exampleSite/hugo_stats.json

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
"fa-activity",
261261
"fa-address-card",
262262
"fa-angle-left",
263+
"fa-angle-right",
264+
"fa-angles-left",
265+
"fa-angles-right",
263266
"fa-arrow-left",
264267
"fa-arrow-right",
265268
"fa-bars",
@@ -379,8 +382,6 @@
379382
"justify-content-between",
380383
"justify-content-center",
381384
"justify-content-end",
382-
"justify-content-md-end",
383-
"justify-content-md-start",
384385
"justify-content-start",
385386
"katex",
386387
"label",
@@ -438,7 +439,6 @@
438439
"multi-docs-collapse-2",
439440
"multi-file-collapse-1",
440441
"mx-auto",
441-
"mx-md-0",
442442
"mx-md-2",
443443
"mx-md-n4",
444444
"my-2",
@@ -583,6 +583,7 @@
583583
"testimonial-img",
584584
"testimonial-logo",
585585
"testimonials",
586+
"text-%!s(<nil>)",
586587
"text-bg-body-tertiary",
587588
"text-bg-info",
588589
"text-bg-light",
@@ -597,8 +598,6 @@
597598
"text-decoration-none",
598599
"text-end",
599600
"text-info",
600-
"text-md-center",
601-
"text-md-end",
602601
"text-muted",
603602
"text-nowrap",
604603
"text-primary",
@@ -735,11 +734,11 @@
735734
"docs",
736735
"documentation",
737736
"dropdown-nav-0",
738-
"dropdown-panel-0efae4d89ba1b34507425ff79e031ff6",
739-
"dropdown-panel-47d1c4c5b870c52880f4d5431bfc8161",
740-
"dropdown-panel-4ece72da2651b717239ac56d5426dd5a",
741-
"dropdown-panel-82d63ff336d6d57ed4f0ffdd17f8267a",
742-
"dropdown-panel-ecea5b8e7ce122a138e33bb6508e82ce",
737+
"dropdown-panel-529c583cb632a4d4aa340c3144559397",
738+
"dropdown-panel-ac14004c1d019760fbd77bae3d8cee5a",
739+
"dropdown-panel-b791b28f1a6830b342ecf4e2cea555f1",
740+
"dropdown-panel-ce74586edf42e3fd5170469a7a08bb5f",
741+
"dropdown-panel-ead6ac83a313db58e6992fc381ae8e92",
743742
"eerste-artikel",
744743
"elements-type",
745744
"entity-relationship-diagram",
@@ -762,11 +761,11 @@
762761
"fab-whatsapp",
763762
"fab-x-twitter",
764763
"faq",
765-
"faq-e61149242eef48ba8815560659885ee3",
766-
"faq-e61149242eef48ba8815560659885ee3-heading-faq-e61149242eef48ba8815560659885ee3",
767-
"faq-e61149242eef48ba8815560659885ee3-item-0",
768-
"faq-e61149242eef48ba8815560659885ee3-item-1",
769-
"faq-e61149242eef48ba8815560659885ee3-item-2",
764+
"faq-97e0b2226faa254e6ce7099907045446",
765+
"faq-97e0b2226faa254e6ce7099907045446-heading-faq-97e0b2226faa254e6ce7099907045446",
766+
"faq-97e0b2226faa254e6ce7099907045446-item-0",
767+
"faq-97e0b2226faa254e6ce7099907045446-item-1",
768+
"faq-97e0b2226faa254e6ce7099907045446-item-2",
770769
"fas-1",
771770
"fas-2",
772771
"fas-3",
@@ -775,6 +774,9 @@
775774
"fas-6",
776775
"fas-address-card",
777776
"fas-angle-left",
777+
"fas-angle-right",
778+
"fas-angles-left",
779+
"fas-angles-right",
778780
"fas-arrow-left",
779781
"fas-arrow-right",
780782
"fas-bars",
@@ -881,11 +883,11 @@
881883
"nav-0-btn-1",
882884
"nav-0-btn-2",
883885
"nav-nav-0",
884-
"nav-panel-0efae4d89ba1b34507425ff79e031ff6",
885-
"nav-panel-47d1c4c5b870c52880f4d5431bfc8161",
886-
"nav-panel-4ece72da2651b717239ac56d5426dd5a",
887-
"nav-panel-82d63ff336d6d57ed4f0ffdd17f8267a",
888-
"nav-panel-ecea5b8e7ce122a138e33bb6508e82ce",
886+
"nav-panel-529c583cb632a4d4aa340c3144559397",
887+
"nav-panel-ac14004c1d019760fbd77bae3d8cee5a",
888+
"nav-panel-b791b28f1a6830b342ecf4e2cea555f1",
889+
"nav-panel-ce74586edf42e3fd5170469a7a08bb5f",
890+
"nav-panel-ead6ac83a313db58e6992fc381ae8e92",
889891
"navbar",
890892
"navbar-0-collapse",
891893
"navbar-mode",
@@ -895,36 +897,36 @@
895897
"notification",
896898
"over-mij",
897899
"overview",
898-
"panel-0efae4d89ba1b34507425ff79e031ff6-0",
899-
"panel-0efae4d89ba1b34507425ff79e031ff6-1",
900-
"panel-0efae4d89ba1b34507425ff79e031ff6-2",
901-
"panel-0efae4d89ba1b34507425ff79e031ff6-btn-0",
902-
"panel-0efae4d89ba1b34507425ff79e031ff6-btn-1",
903-
"panel-0efae4d89ba1b34507425ff79e031ff6-btn-2",
904-
"panel-47d1c4c5b870c52880f4d5431bfc8161-0",
905-
"panel-47d1c4c5b870c52880f4d5431bfc8161-1",
906-
"panel-47d1c4c5b870c52880f4d5431bfc8161-2",
907-
"panel-47d1c4c5b870c52880f4d5431bfc8161-btn-0",
908-
"panel-47d1c4c5b870c52880f4d5431bfc8161-btn-1",
909-
"panel-47d1c4c5b870c52880f4d5431bfc8161-btn-2",
910-
"panel-4ece72da2651b717239ac56d5426dd5a-0",
911-
"panel-4ece72da2651b717239ac56d5426dd5a-1",
912-
"panel-4ece72da2651b717239ac56d5426dd5a-2",
913-
"panel-4ece72da2651b717239ac56d5426dd5a-btn-0",
914-
"panel-4ece72da2651b717239ac56d5426dd5a-btn-1",
915-
"panel-4ece72da2651b717239ac56d5426dd5a-btn-2",
916-
"panel-82d63ff336d6d57ed4f0ffdd17f8267a-0",
917-
"panel-82d63ff336d6d57ed4f0ffdd17f8267a-1",
918-
"panel-82d63ff336d6d57ed4f0ffdd17f8267a-2",
919-
"panel-82d63ff336d6d57ed4f0ffdd17f8267a-btn-0",
920-
"panel-82d63ff336d6d57ed4f0ffdd17f8267a-btn-1",
921-
"panel-82d63ff336d6d57ed4f0ffdd17f8267a-btn-2",
922-
"panel-ecea5b8e7ce122a138e33bb6508e82ce-0",
923-
"panel-ecea5b8e7ce122a138e33bb6508e82ce-1",
924-
"panel-ecea5b8e7ce122a138e33bb6508e82ce-2",
925-
"panel-ecea5b8e7ce122a138e33bb6508e82ce-btn-0",
926-
"panel-ecea5b8e7ce122a138e33bb6508e82ce-btn-1",
927-
"panel-ecea5b8e7ce122a138e33bb6508e82ce-btn-2",
900+
"panel-529c583cb632a4d4aa340c3144559397-0",
901+
"panel-529c583cb632a4d4aa340c3144559397-1",
902+
"panel-529c583cb632a4d4aa340c3144559397-2",
903+
"panel-529c583cb632a4d4aa340c3144559397-btn-0",
904+
"panel-529c583cb632a4d4aa340c3144559397-btn-1",
905+
"panel-529c583cb632a4d4aa340c3144559397-btn-2",
906+
"panel-ac14004c1d019760fbd77bae3d8cee5a-0",
907+
"panel-ac14004c1d019760fbd77bae3d8cee5a-1",
908+
"panel-ac14004c1d019760fbd77bae3d8cee5a-2",
909+
"panel-ac14004c1d019760fbd77bae3d8cee5a-btn-0",
910+
"panel-ac14004c1d019760fbd77bae3d8cee5a-btn-1",
911+
"panel-ac14004c1d019760fbd77bae3d8cee5a-btn-2",
912+
"panel-b791b28f1a6830b342ecf4e2cea555f1-0",
913+
"panel-b791b28f1a6830b342ecf4e2cea555f1-1",
914+
"panel-b791b28f1a6830b342ecf4e2cea555f1-2",
915+
"panel-b791b28f1a6830b342ecf4e2cea555f1-btn-0",
916+
"panel-b791b28f1a6830b342ecf4e2cea555f1-btn-1",
917+
"panel-b791b28f1a6830b342ecf4e2cea555f1-btn-2",
918+
"panel-ce74586edf42e3fd5170469a7a08bb5f-0",
919+
"panel-ce74586edf42e3fd5170469a7a08bb5f-1",
920+
"panel-ce74586edf42e3fd5170469a7a08bb5f-2",
921+
"panel-ce74586edf42e3fd5170469a7a08bb5f-btn-0",
922+
"panel-ce74586edf42e3fd5170469a7a08bb5f-btn-1",
923+
"panel-ce74586edf42e3fd5170469a7a08bb5f-btn-2",
924+
"panel-ead6ac83a313db58e6992fc381ae8e92-0",
925+
"panel-ead6ac83a313db58e6992fc381ae8e92-1",
926+
"panel-ead6ac83a313db58e6992fc381ae8e92-2",
927+
"panel-ead6ac83a313db58e6992fc381ae8e92-btn-0",
928+
"panel-ead6ac83a313db58e6992fc381ae8e92-btn-1",
929+
"panel-ead6ac83a313db58e6992fc381ae8e92-btn-2",
928930
"panels",
929931
"persona",
930932
"pie-chart",
@@ -963,7 +965,7 @@
963965
"tabs",
964966
"team",
965967
"testimonial",
966-
"testimonial-carousel-93eb220a6fef19ea1a16ae43ac24bcd3",
968+
"testimonial-carousel-1b351213617c94546d1f4b98565c71b7",
967969
"testimonials",
968970
"testimonials-type",
969971
"third-party-links--use-of-your-information",

layouts/_markup/render-link.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{ partial "assets/link.html" (dict
1010
"href" .Destination
1111
"page" .Page
12-
"text" .Text
13-
"title" .Title
12+
"text" (.Text | htmlUnescape)
13+
"title" (.Title | htmlUnescape)
1414
) }}
1515
{{- end }}

layouts/_partials/assets/live-pages.html

Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--
1+
<!--
22
Copyright © 2024 - 2025 The Hinode Team / Mark Dumay. All rights reserved.
33
-->
44

@@ -17,6 +17,7 @@
1717
{{/* Initialize local arguments */}}
1818
{{ $pages := slice }}
1919
{{ $total := 0 }}
20+
{{ $menu := slice }}
2021

2122
{{/* Main code */}}
2223
{{ if not $args.err }}
@@ -76,13 +77,104 @@
7677
{{ $pages = where $pages "Params.categories" "intersect" $categories }}
7778
{{ end }}
7879
{{ end }}
79-
80-
{{/* Sort the pages as specified */}}
80+
81+
{{/* Include the list pages if requested */}}
82+
{{- $lists := slice -}}
83+
{{ if or $args.includeList (eq $args.groupBy "section") }}
84+
{{ range $pages }}
85+
{{ $lists = $lists | append .Parent | uniq }}
86+
{{ end }}
87+
{{ $pages = $pages | append $lists }}
88+
{{ end }}
89+
90+
{{/* Sort the pages as specified */}}
91+
{{- $sortField := printf "Params.%s" $args.sort -}}
8192
{{- $order := "asc" -}}
8293
{{- if $args.reverse }}{{ $order = "desc" }}{{ end -}}
83-
{{- $pages = sort $pages (printf "Params.%s" $args.sort) $order -}}
94+
95+
{{ if eq $args.groupBy "section" }}
96+
{{- /* Build a hierarchical map: parent path -> slice of children */ -}}
97+
{{- $grouped := dict -}}
98+
{{- $rootPages := slice -}}
99+
100+
{{- range $page := $pages -}}
101+
{{- if $page.Parent -}}
102+
{{- $parentPath := $page.Parent.RelPermalink -}}
103+
{{- $childrenSlice := index $grouped $parentPath | default slice -}}
104+
{{- $grouped = merge $grouped (dict $parentPath ($childrenSlice | append $page)) -}}
105+
{{- else -}}
106+
{{- $rootPages = $rootPages | append $page -}}
107+
{{- end -}}
108+
{{- end -}}
109+
110+
{{- /* If a section was specified, use that section page as the root */ -}}
111+
{{- if $args.section -}}
112+
{{- $sectionPage := site.GetPage $args.section -}}
113+
{{- if $sectionPage -}}
114+
{{- $rootPages = slice | append $sectionPage -}}
115+
{{- end -}}
116+
{{- end -}}
117+
118+
{{- /* Sort root pages first */ -}}
119+
{{- $rootPages = sort $rootPages $sortField $order -}}
120+
121+
{{- /* Process depth-first (pre-order): use a stack to traverse */ -}}
122+
{{- $result := slice -}}
123+
{{- $stack := slice -}}
124+
125+
{{- /* Initialize stack with root pages: always push in reverse for LIFO to pop in correct order */ -}}
126+
{{- if $rootPages -}}
127+
{{- range $i := seq (len $rootPages) -}}
128+
{{- $idx := sub (len $rootPages) $i -}}
129+
{{- $page := index $rootPages $idx -}}
130+
{{- $stack = $stack | append $page -}}
131+
{{- end -}}
132+
{{- end -}}
133+
134+
{{- range $iteration := seq 1 1000 -}}
135+
{{- /* Exit if stack is empty */ -}}
136+
{{- if not $stack -}}
137+
{{- break -}}
138+
{{- end -}}
139+
140+
{{- /* Pop from stack */ -}}
141+
{{- $stackSize := len $stack -}}
142+
{{- $lastIdx := sub $stackSize 1 -}}
143+
{{- $current := index $stack $lastIdx -}}
144+
{{- $stack = $stack | first $lastIdx -}}
145+
146+
{{- /* Add current page to result */ -}}
147+
{{- $result = $result | append $current -}}
148+
149+
{{- /* Get and sort children */ -}}
150+
{{- $pageKey := $current.RelPermalink -}}
151+
{{- $children := index $grouped $pageKey | default slice -}}
152+
{{- if $children -}}
153+
{{- $children = sort $children $sortField $order -}}
154+
{{- /* Push children to stack in reverse so LIFO pops in correct order */ -}}
155+
{{- range $i := seq (len $children) -}}
156+
{{- $idx := sub (len $children) $i -}}
157+
{{- $child := index $children $idx -}}
158+
{{- $stack = $stack | append $child -}}
159+
{{- end -}}
160+
{{- end -}}
161+
{{- end -}}
162+
163+
{{- $pages = $result -}}
164+
165+
{{/* Build menu structure from sorted pages and hierarchy */}}
166+
{{- range $rootPages -}}
167+
{{- $menuEntry := partial "assets/helpers/buildMenuEntry" (dict "page" . "grouped" $grouped) -}}
168+
{{- $menu = $menu | append $menuEntry -}}
169+
{{- end -}}
170+
{{ else }}
171+
{{- /* Use regular sort */ -}}
172+
{{- $pages = sort $pages $sortField $order -}}
173+
{{- /* For non-grouped sorts, use pages directly as menu */ -}}
174+
{{- $menu = $pages | default slice -}}
175+
{{ end }}
84176
{{ end }}
85177
{{ end }}
86178
{{ end }}
87179

88-
{{ return (dict "pages" $pages "total" $total) }}
180+
{{ return (dict "pages" $pages "menu" $menu "total" $total) }}

0 commit comments

Comments
 (0)