From 66f4fbf5f04db1aa128d8f951c0883cc226312b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 15 Dec 2024 15:34:50 +0100 Subject: [PATCH] details: add shortcode #957 --- .../introduction/releasenotes/7/3.en.md | 13 +++++++++++ exampleSite/content/shortcodes/expand.en.md | 2 ++ .../_default/_markup/render-blockquote.html | 2 +- layouts/partials/version.txt | 2 +- layouts/shortcodes/details.html | 23 +++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 exampleSite/content/introduction/releasenotes/7/3.en.md create mode 100644 layouts/shortcodes/details.html diff --git a/exampleSite/content/introduction/releasenotes/7/3.en.md b/exampleSite/content/introduction/releasenotes/7/3.en.md new file mode 100644 index 0000000000..c53de23e19 --- /dev/null +++ b/exampleSite/content/introduction/releasenotes/7/3.en.md @@ -0,0 +1,13 @@ ++++ +disableToc = false +hidden = true +title = "Version 7.3" +type = "releasenotes" +weight = -3 ++++ + +## 7.3.0 (XXXX-XX-XX) {#7-3-0} + +### New + +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Support for Hugo’s built-in [`details` shortcode](https://gohugo.io/content-management/shortcodes/#details) by mapping it to the theme's [`expand` shortcode](shortcodes/expand). diff --git a/exampleSite/content/shortcodes/expand.en.md b/exampleSite/content/shortcodes/expand.en.md index 24f6a85e2a..d9aec115ce 100644 --- a/exampleSite/content/shortcodes/expand.en.md +++ b/exampleSite/content/shortcodes/expand.en.md @@ -62,6 +62,8 @@ That's some more text with a footnote.[^someid] The [`notice` shortcode](shortcodes/notice) is also capable of displaying expandable/collapsible sections of text but with additional parameter for color and additional icons. +The theme supports Hugo’s built-in [`details` shortcode](https://gohugo.io/content-management/shortcodes/#details) by mapping the parameter to the theme's `expand` shortcode. + ### Parameter | Name | Position | Default | Notes | diff --git a/layouts/_default/_markup/render-blockquote.html b/layouts/_default/_markup/render-blockquote.html index 87cb807bb0..2be12e7533 100644 --- a/layouts/_default/_markup/render-blockquote.html +++ b/layouts/_default/_markup/render-blockquote.html @@ -11,9 +11,9 @@ {{- partial "shortcodes/notice.html" (dict "page" .Page "content" $text + "expanded" (cond (eq $alertsign "+") true (cond (eq $alertsign "-") false "")) "style" $alerttype "title" $alerttitle - "expanded" (cond (eq $alertsign "+") true (cond (eq $alertsign "-") false "")) ) }} {{ else -}}
diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index 468c41f93c..2c9a2947af 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.2.1 \ No newline at end of file +7.2.1+16d4de84becfa2d2e6bdb2394a2f4fa411bc0007 \ No newline at end of file diff --git a/layouts/shortcodes/details.html b/layouts/shortcodes/details.html new file mode 100644 index 0000000000..ff3213d91f --- /dev/null +++ b/layouts/shortcodes/details.html @@ -0,0 +1,23 @@ +{{- $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 }} +{{- $params := dict }} +{{- with (.Get "class") }} + {{- $params = $params | merge (dict "class" .) }} +{{- end }} +{{- with (.Get "title") }} + {{- $params = $params | merge (dict "title" .) }} +{{- end }} +{{- partial "shortcodes/notice.html" (dict + "page" .Page + "content" .Inner + "expanded" $open + "groupid" (.Get "name") + "params" $params + "style" "transparent" + "title" $summary +) }} \ No newline at end of file