mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-17 15:03:20 +00:00
44 lines
1.6 KiB
HTML
44 lines
1.6 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" "carousel-item" "args" .Params "group" "shortcode" ) }}
|
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
<!-- Initialize arguments -->
|
|
{{ if not .Parent }}
|
|
{{ errorf "The img shortcode should be contained within a carousel shortcode: %s" .Position }}
|
|
{{ else if not $error }}
|
|
{{- $src := .Get "src" | default "" -}}
|
|
{{- $caption := .Get "caption" | default "" -}}
|
|
{{- $ratio := partial "utilities/GetArgParent" (dict "page" . "arg" "ratio") -}}
|
|
{{- $portrait := partial "utilities/GetArgParent" (dict "page" . "arg" "portrait") | default false -}}
|
|
{{- $active := .Get "active" | default (eq .Ordinal 0) -}}
|
|
{{- $loading := .Get "loading" | default "eager" -}}
|
|
|
|
<!-- Main code -->
|
|
{{- $output := partial "assets/carousel-item.html" (dict
|
|
"page" .Page
|
|
"active" $active
|
|
"src" $src
|
|
"caption" $caption
|
|
"ratio" $ratio
|
|
"portrait" $portrait
|
|
"loading" $loading
|
|
) }}
|
|
|
|
{{ $current := .Parent.Scratch.Get "inner" }}
|
|
{{ if $current }}
|
|
{{ .Parent.Scratch.Set "inner" (print $current $output) }}
|
|
{{ else }}
|
|
{{ .Parent.Scratch.Set "inner" $output }}
|
|
{{ end }}
|
|
{{ end -}}
|