mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-17 06:53:11 +00:00
100 lines
3.8 KiB
HTML
100 lines
3.8 KiB
HTML
<!--
|
|
Copyright © 2024 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 }}
|
|
|
|
<!-- Validate arguments -->
|
|
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "card" "args" .Params) }}
|
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
<!-- Initialize arguments and default values -->
|
|
{{- $alt := .Get "alt" -}}
|
|
{{- $class := partial "utilities/GetArgParent" (dict "page" . "arg" "class" "merge" true) -}}
|
|
{{- $color := partial "utilities/GetArgParent" (dict "page" . "arg" "color") -}}
|
|
{{- $description := trim .Inner " \r\n" | .Page.RenderString | safeHTML -}}
|
|
{{- $footer := partial "utilities/GetArgParent" (dict "page" . "arg" "footer") | default "none" -}}
|
|
{{- $gutter := partial "utilities/GetArgParent" (dict "page" . "arg" "gutter") | default "0" -}}
|
|
{{- $header := partial "utilities/GetArgParent" (dict "page" . "arg" "header") | default "full" -}}
|
|
{{- $icon := .Get "icon" -}}
|
|
{{- $iconRounded := partial "utilities/GetArgParent" (dict "page" . "arg" "iconRounded") | default false -}}
|
|
{{- $align := partial "utilities/GetArgParent" (dict "page" . "arg" "align") | default "start" -}}
|
|
{{- $style := partial "utilities/GetArgParent" (dict "page" . "arg" "style") | default "" -}}
|
|
{{- $subtle := partial "utilities/GetArgParent" (dict "page" . "arg" "subtle") | default false -}}
|
|
{{- $loading := .Get "loading" -}}
|
|
{{- $orientation := partial "utilities/GetArgParent" (dict "page" . "arg" "orientation") | default "stacked" -}}
|
|
{{- $padding := partial "utilities/GetArgParent" (dict "page" . "arg" "padding") | default "auto" -}}
|
|
{{- $ratio := partial "utilities/GetArgParent" (dict "page" . "arg" "ratio") | default "" -}}
|
|
{{- $page := .Page -}}
|
|
{{- $path := .Get "path" -}}
|
|
{{- $thumbnail := .Get "thumbnail" -}}
|
|
{{- $title := .Get "title" -}}
|
|
{{- $button := partial "utilities/GetArgParent" (dict "page" . "arg" "button") | default false -}}
|
|
{{- $buttonType := partial "utilities/GetArgParent" (dict "page" . "arg" "buttonType") | default "" -}}
|
|
{{- $cols := partial "utilities/GetArgParent" (dict "page" . "arg" "cols") | default 3 -}}
|
|
{{- $scroll := partial "utilities/GetArgParent" (dict "page" . "arg" "scroll") | default false -}}
|
|
{{- $wrapper := "" -}}
|
|
|
|
<!-- Override arguments -->
|
|
{{ if $path }}
|
|
{{ $page = $.Site.GetPage $path }}
|
|
{{ if not $page }}
|
|
{{ errorf "Invalid or missing value for param 'path': %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ if .Parent }}
|
|
{{ $class = (printf "h-100 %s" $class) }}
|
|
{{ end }}
|
|
|
|
{{ if $scroll }}
|
|
{{ $wrapper = printf "card-block-%d p-0" $cols }}
|
|
{{ end }}
|
|
|
|
|
|
<!-- Main code -->
|
|
{{ if not $error -}}
|
|
<!-- Render card -->
|
|
{{- $output := partial "assets/card.html" (dict
|
|
"path" $path
|
|
"title" $title
|
|
"class" $class
|
|
"gutter" $gutter
|
|
"color" $color
|
|
"padding" $padding
|
|
"header" $header
|
|
"footer" $footer
|
|
"orientation" $orientation
|
|
"description" $description
|
|
"ratio" $ratio
|
|
"icon" $icon
|
|
"iconRounded" $iconRounded
|
|
"align" $align
|
|
"style" $style
|
|
"subtle" $subtle
|
|
"scroll" $scroll
|
|
"wrapper" $wrapper
|
|
"thumbnail" $thumbnail
|
|
"loading" $loading
|
|
"alt" $alt
|
|
"button" $button
|
|
"buttonType" $buttonType
|
|
) -}}
|
|
|
|
<!-- Pass output to parent or current stream -->
|
|
{{ with .Parent }}
|
|
{{ $current := .Scratch.Get "inner" }}
|
|
{{ if $current }}
|
|
{{ .Scratch.Set "inner" (print $current $output) }}
|
|
{{ else }}
|
|
{{ .Scratch.Set "inner" $output }}
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ print $output | safeHTML }}
|
|
{{ end }}
|
|
{{ end -}} |