Files
hinode/component-library/components/articles/articles.hugo.html
2025-06-23 12:40:51 +02:00

107 lines
3.5 KiB
HTML

{{/*
Copyright © 2025 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
*/}}
{{ $error := false }}
{{/* Initialize arguments */}}
{{ $args := partial "utilities/InitArgs.html" (dict "bookshop" "articles" "args" .)}}
{{ if or $args.err $args.warnmsg }}
{{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
"partial" "component-library/components/articles/articles.hugo.html"
"warnid" "warn-invalid-arguments"
"msg" "Invalid arguments"
"details" ($args.errmsg | append $args.warnmsg)
"file" page.File
)}}
{{ $error = $args.err }}
{{ end }}
{{ $pages := slice }}
{{ $result := partial "assets/live-pages.html" (dict
"page" $args.page
"section" $args.input.section
"nested" $args.input.nested
"keywords" $args.input.keywords
"categories" $args.input.categories
"tags" $args.input.tags
"sort" $args.input.sort
"reverse" $args.input.reverse
)}}
{{ $pages = $result.pages }}
<!-- Add style definitions -->
{{ $styles := slice
(dict "ratio" "1x1" "orientation" "overlay" "portrait" false "width" "6")
(dict "ratio" "4x3" "orientation" "stacked" "portrait" true "width" "3")
(dict "ratio" "1x1" "orientation" "stacked" "portrait" false "width" "3")
(dict "ratio" "16x9" "orientation" "stacked" "portrait" true "width" "3")
(dict "ratio" "1x1" "orientation" "stacked" "portrait" false "width" "3")
}}
<!-- Define more button -->
{{ $moreButton := site.Params.modules.bookshop.articles.moreButton | default false }}
{{ $moreTitle := T "more" (pluralize $args.input.section) }}
{{ $moreLink := $args.input.section }}
{{ with $args.more }}
{{ if .title }}{{ $moreTitle = .title }}{{ end }}
{{ if .link }}{{ $moreLink = .link }}{{ end }}
{{ end }}
{{ $paginate := $args.paginate }}
{{ if and $paginate page.IsPage }}
{{ partial "utilities/LogWarn.html" (dict
"partial" "component-library/components/articles/articles.hugo.html"
"msg" "Pagination not supported"
"file" page.File
)}}
{{ $paginate = false }}
{{ end }}
<!-- Main code -->
{{ if not $error }}
{{- partial "assets/section-title.html" (dict "heading" $args.heading) -}}
{{ $partial := "assets/card-group.html" }}
{{ $params := dict }}
{{- $params = merge $params (dict
"page" page
"list" $pages
"limit" $args.limit
"cols" $args.cols
"icon-rounded" $args.iconRounded
"href" (cond $moreButton $moreLink "")
"href-title" (cond $moreButton $moreTitle "")
"href-force" (gt $result.total (len $result.pages))
)}}
{{ if $args.scroll }}
{{ $partial := "assets/stack.html" }}
{{ $params = merge $params (dict
"header-style" "none"
"body-style" "title"
"footer-style" "none"
"gutter" 1
"padding" 3
"ratio" "1x1"
"orientation" "horizontal-sm"
"styles" (cond $args.bento $styles "")
) -}}
{{ else }}
{{ $params = merge $params (dict
"header-style" $args.headerStyle
"footer-style" $args.footerStyle
"padding" $args.padding
"class" (or $args.class "border-0")
"icon-style" "fa-2x"
"align" "start"
"orientation" $args.orientation
"hook" "assets/live-card.html"
"pagination" $args.pagination
"paginate" $paginate
) -}}
{{ end }}
{{ partial $partial $params }}
{{ end }}