1+ {{/*
2+ Copyright © 2025 The Hinode Team / Mark Dumay. All rights reserved.
3+ Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
4+ Visit gethinode.com/license for more details.
5+ */}}
6+
7+ {{ $error := false }}
8+
9+ {{/* Initialize arguments */}}
10+ {{ $args := partial "utilities/InitArgs.html" (dict "bookshop" "list" "args" .)}}
11+ {{ if or $args.err $args.warnmsg }}
12+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
13+ "partial" "component-library/components/list/list.hugo.html"
14+ "warnid" "warn-invalid-arguments"
15+ "msg" "Invalid arguments"
16+ "details" ($args.errmsg | append $args.warnmsg)
17+ "file" page.File
18+ )}}
19+ {{ $error = $args.err }}
20+ {{ end }}
21+
22+ {{/* Initialize global arguments */}}
23+ {{- $padding := partial "utilities/GetPadding.html" -}}
24+
25+ {{/* Ensure to include the simple-datatables module */}}
26+ {{/* TODO: fix add module handling, requires propagating scratch variables to correct page */}}
27+ {{ partial "utilities/AddModule.html" (dict "page" $args._page "module" "simple-datatables" ) }}
28+
29+ {{/* Initialize local variables */}}
30+ {{ $pages := slice }}
31+ {{ $result := partial "assets/live-pages.html" (dict
32+ "page" $args._page
33+ "section" $args.input.section
34+ "nested" $args.input.nested
35+ "keywords" $args.input.keywords
36+ "categories" $args.input.categories
37+ "tags" $args.input.tags
38+ "sort" $args.input.sort
39+ "reverse" $args.input.reverse
40+ )}}
41+ {{ $pages = $result.pages }}
42+
43+ {{ if and $args.limit $args.paginate }}
44+ {{ partial "utilities/LogWarn.html" (dict
45+ "partial" "component-library/components/list/list.hugo.html"
46+ "msg" "Limit is ignored when paginate is set"
47+ "file" page.File
48+ )}}
49+ {{ end }}
50+
51+ {{/* Limit list to max elements */}}
52+ {{- $count := len $pages -}}
53+ {{- $max := $count -}}
54+ {{- $max = math.Min ($args.limit | default $count) $count -}}
55+ {{- if not $args.paginate -}}
56+ {{- $pages = first $max $pages -}}
57+ {{- end -}}
58+
59+ {{/* Main code */}}
60+ {{ if not $error }}
61+ {{ if or (gt (len $pages) 0) (not $args.hideEmpty) }}
62+ {{- partial "assets/section-title.html" (dict
63+ "heading" $args.heading
64+ "justify" $args.justify
65+ "class" (printf "pb-%d" $padding.y))
66+ -}}
67+ {{ if gt (len $pages) 0 }}
68+ {{ $content := "" }}
69+ {{ if $args.hook }}
70+ {{ $content = partial $args.hook (dict "pages" $pages) }}
71+ {{ else }}
72+ {{ $content = "| Title | Description |\n|-|-|\n" }}
73+ {{ range $pages }}
74+ {{ $content = printf "%s[%s](#%s) | %s |\n" $content .LinkTitle .RelPermalink .Description }}
75+ {{ end }}
76+ {{ end }}
77+
78+ {{- /* Define main breakpoint */ -}}
79+ {{- $args.page.Scratch.Set "breakpoint" (partialCached "utilities/GetBreakpoint.html" .) }}
80+
81+ {{ $pagination := $args.pagination | default 10 }}
82+ {{ $paginate := and $args.paginate (gt (len $pages) $pagination) }}
83+ {{ $sortable := and $args.sortable (gt (len $pages) 1) }}
84+ {{ $searchable := and $args.searchable (gt (len $pages) 1) }}
85+
86+ {{ partial "assets/table.html" (dict
87+ "page" (or $args.page page)
88+ "input" $content
89+ "breakpoint" $args.breakpoint
90+ "class" $args.class
91+ "sortable" $sortable
92+ "paginate" $paginate
93+ "pagination" (cond $paginate $pagination "")
94+ "pagination-select" (cond $paginate $args.paginationSelect "")
95+ "searchable" $searchable
96+ "wrap" $args.wrap
97+ "_default" $args.default
98+ ) }}
99+ {{ else }}
100+ < p class ="pt-{{ $padding.y }} "> {{- T "emptyList" }}.</ p >
101+ {{ end }}
102+ {{ end }}
103+ {{ end }}
0 commit comments