mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-17 23:13:11 +00:00
117 lines
5.1 KiB
HTML
117 lines
5.1 KiB
HTML
<!--
|
|
Displays a Bootstrap card that links to a page. Any inner text is used as description The shortcode supports the
|
|
following arguments:
|
|
"path" Optional path of the page. If omitted, specify the title, icon, thumbnail, and body as needed.
|
|
"title" Optional title of the card.
|
|
"class" Optional class attribute of the card element, e.g. “w-50”.
|
|
"color" Optional theme color of the card, either "primary", "secondary", "success", "danger",
|
|
"warning", "info", "light", "dark", "white", "black", "body", or "body-tertiary". By default, no
|
|
color is specified.
|
|
"padding" Optional padding of the content, either "0", "1", "2", "3", "4", "5", or "auto" (default).
|
|
"gutter" Gutter between columns in a group, either "0" (default), "1", "2", "3", "4", or "5".
|
|
"header" Optional header components of the card, displayed in small caps. Supported values are "full"
|
|
(default), "publication", "tags", and "none".
|
|
"footer" Optional footer components of the card, displayed in small caps. Supported values are "full",
|
|
"publication", "tags", and "none" (default).
|
|
"orientation" Optional placecement of the thumbnail, either "stacked" (default), "horizontal", or "none".
|
|
"thumbnail" Optional thumbnail image url, displayed on top or the left of the card.
|
|
"alt" Optional alternate text for the thumbnail, uses "title" by default.
|
|
"icon" Optional Font Awesome icon, displayed on top or the left of the card.
|
|
-->
|
|
|
|
{{ $error := false }}
|
|
|
|
{{ $path := or (.Get "path") "" }}
|
|
{{ $page := .Page }}
|
|
{{ with $path }}
|
|
{{ $page = $.Site.GetPage $path }}
|
|
{{ if not $page }}
|
|
{{ errorf "Invalid or missing value for param 'path': %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{- $class := partial "utilities/GetArg" (dict "page" . "arg" "class" "merge" true) -}}
|
|
|
|
{{- $color := partial "utilities/GetArg" (dict "page" . "arg" "color") -}}
|
|
{{ if $color }}
|
|
{{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" "white" "black" "body" "body-tertiary" -}}
|
|
{{ if not (in $supportedColors $color) -}}
|
|
{{ errorf "Invalid value for param 'color': %s" .Position -}}
|
|
{{ $error = true -}}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
|
|
{{- $header := partial "utilities/GetArg" (dict "page" . "arg" "header") | default "full" -}}
|
|
{{ $supportedKeywords := slice "full" "publication" "tags" "none" -}}
|
|
{{ if not (in $supportedKeywords $header) -}}
|
|
{{ errorf "Invalid value for param 'header': %s" .Position -}}
|
|
{{ end -}}
|
|
|
|
{{- $footer := partial "utilities/GetArg" (dict "page" . "arg" "footer") | default "none" -}}
|
|
{{ if not (in $supportedKeywords $footer) -}}
|
|
{{ errorf "Invalid value for param 'footer': %s" .Position -}}
|
|
{{ end -}}
|
|
|
|
{{- $padding := partial "utilities/GetArg" (dict "page" . "arg" "padding") | default "auto" -}}
|
|
{{ $supportedPaddings := slice "0" "1" "2" "3" "4" "5" "auto" -}}
|
|
{{ if not (in $supportedPaddings $padding) -}}
|
|
{{ errorf "Invalid value for param 'padding': %s" .Position -}}
|
|
{{ $error = true -}}
|
|
{{ end -}}
|
|
|
|
{{- $gutter := partial "utilities/GetArg" (dict "page" . "arg" "gutter") | default "0" -}}
|
|
{{ $supportedGutters:= slice "0" "1" "2" "3" "4" "5" -}}
|
|
{{ if not (in $supportedGutters $gutter) -}}
|
|
{{ errorf "Invalid value for param 'gutter': %s" .Position -}}
|
|
{{ $error = true -}}
|
|
{{ end -}}
|
|
|
|
{{- $orientation := partial "utilities/GetArg" (dict "page" . "arg" "orientation") | default "stacked" -}}
|
|
{{ $supportedOrientations := slice "stacked" "horizontal" "none" -}}
|
|
{{ if not (in $supportedOrientations $orientation) -}}
|
|
{{ errorf "Invalid value for param 'orientation': %s" .Position -}}
|
|
{{ $error = true -}}
|
|
{{ end -}}
|
|
|
|
{{- $layout := partial "utilities/GetArg" (dict "page" . "arg" "layout") | default "rich" -}}
|
|
{{ $supportedLayouts := slice "rich" "minimal" -}}
|
|
{{ if not (in $supportedLayouts $layout) -}}
|
|
{{ errorf "Invalid value for param 'layout': %s" .Position -}}
|
|
{{ $error = true -}}
|
|
{{ end -}}
|
|
|
|
{{ $description := trim .Inner " \r\n" | .Page.RenderString | safeHTML }}
|
|
{{ $title := .Get "title" | default "" -}}
|
|
{{ $alt := .Get "alt" | default "" -}}
|
|
{{ $icon := .Get "icon" | default "" -}}
|
|
{{ $thumbnail := .Get "thumbnail" | default "" -}}
|
|
|
|
{{ if not $error -}}
|
|
{{- $output := partial "assets/card.html" (dict
|
|
"path" $path
|
|
"title" $title
|
|
"class" (printf "h-100 %s" $class)
|
|
"gutter" $gutter
|
|
"color" $color
|
|
"padding" $padding
|
|
"header" $header
|
|
"footer" $footer
|
|
"orientation" $orientation
|
|
"description" $description
|
|
"icon" $icon
|
|
"thumbnail" $thumbnail
|
|
"alt" $alt
|
|
) -}}
|
|
|
|
{{ 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 -}} |