From b03a0f508a86e6919ea8f8519f38cc2c29e53fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 1 Dec 2024 22:17:19 +0100 Subject: [PATCH] details: support built-in Hugo shortcode #957 --- layouts/partials/shortcodes/notice.html | 28 ++++++++++++++++++++++++- layouts/partials/version.txt | 2 +- layouts/shortcodes/details.html | 15 +++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 layouts/shortcodes/details.html diff --git a/layouts/partials/shortcodes/notice.html b/layouts/partials/shortcodes/notice.html index d0629a2589..988e137e1c 100644 --- a/layouts/partials/shortcodes/notice.html +++ b/layouts/partials/shortcodes/notice.html @@ -32,9 +32,35 @@ {{- $expander = true }} {{- end }} {{- end }} +{{- $params := .params | default dict }} +{{- $classes := split (index $params "class" | default "") " " }} +{{- $classes = $classes | append "box" }} +{{- $classes = $classes | append "cstyle" }} +{{- $classes = $classes | append $class }} +{{- $classes = $classes | append $style }} +{{- if $expander }} + {{- $classes = $classes | append "expand" }} +{{- else }} + {{- $expanded = true }} +{{- end }} +{{- $params = dict "class" (delimit $classes " ") | merge $params }} +{{- if $color }} + {{- $styles := split (index $params "style" | default "") ";" }} + {{- $styles = $styles | append "--VARIABLE-BOX-color: {{ $color }}" }} + {{- $params = dict "style" (delimit $styles ";") | merge $params }} +{{- end }} +{{ if $groupid }} + {{- $params = dict "name" $groupid | merge $params }} +{{- end }} {{- with $page }} {{- if or $icon $title $hasContent -}} -
+
{{ if $expander }} {{ end }}{{ if $icon }} {{ end }}{{ if $title }} diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index a5afd129f5..c226a1d993 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.1.1+62b52bb8680225e7de2ff0442813709ae1e14bc0 \ No newline at end of file +7.1.1+39fcbb328323656eda3acf6911adb446bd439fe5 \ No newline at end of file diff --git a/layouts/shortcodes/details.html b/layouts/shortcodes/details.html new file mode 100644 index 0000000000..516f8f3f53 --- /dev/null +++ b/layouts/shortcodes/details.html @@ -0,0 +1,15 @@ +{{- $summary := (.Get "summary") | default (T "Details") }} +{{- $open := false }} +{{- if in (slice "false" false 0) (.Get "open") }} + {{- $open = false }} +{{- else if in (slice "true" true 1) (.Get "open")}} + {{- $open = true }} +{{- end }} +{{- partial "shortcodes/notice.html" (dict + "page" .Page + "content" .Inner + "expanded" $open + "params" .Params + "style" "transparent" + "title" $summary +) }} \ No newline at end of file