From 750766a4452bcb5242b81c4f2b405fb6dd0a6b44 Mon Sep 17 00:00:00 2001 From: Alex Haslam Date: Sat, 31 Jan 2026 20:02:19 +0000 Subject: [PATCH] Add separated flag --- exampleSite/content/docs/shortcodes/index.md | 9 +++++---- layouts/shortcodes/accordion.html | 19 ++++++++++++++++++- layouts/shortcodes/accordionItem.html | 13 ++++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/exampleSite/content/docs/shortcodes/index.md b/exampleSite/content/docs/shortcodes/index.md index 47dee3fa..d81b5532 100644 --- a/exampleSite/content/docs/shortcodes/index.md +++ b/exampleSite/content/docs/shortcodes/index.md @@ -103,7 +103,8 @@ The alert sign (`+` or `-`) is optional to control whether the admonition is fol | Parameter | Description | | --------- | ------------------------------------------------------------------------------------------------- | -| `mode` | **Optional.** `collapse` (single open) or `open` (multiple open). Defaults to `collapse`. | +| `mode` | **Optional.** `collapse` (single open) or `open` (multiple open). Defaults to `collapse`. | +| `separated` | **Optional.** `true` to show each item as a separate card. Defaults to `false` (joined list). | `accordionItem` parameters: @@ -116,10 +117,10 @@ The alert sign (`+` or `-`) is optional to control whether the admonition is fol | `header` | **Optional.** Alias for `title`, kept for compatibility with other shortcodes. | -**Example 1: `mode="open"` (multiple items can be open)** +**Example 1: `mode="open"` (multiple items can be open) + `separated=true`** ```md -{{}} +{{}} {{}} Blowfish is a fast, configurable Hugo theme. {{}} @@ -130,7 +131,7 @@ The alert sign (`+` or `-`) is optional to control whether the admonition is fol {{}} ``` -{{< accordion mode="open" >}} +{{< accordion mode="open" separated=true >}} {{< accordionItem title="What is Blowfish?" open=true >}} Blowfish is a fast, configurable Hugo theme. {{< /accordionItem >}} diff --git a/layouts/shortcodes/accordion.html b/layouts/shortcodes/accordion.html index 07ef7f2c..d4ef39e0 100644 --- a/layouts/shortcodes/accordion.html +++ b/layouts/shortcodes/accordion.html @@ -1,9 +1,26 @@ {{ $id := delimit (slice "accordion" (partial "functions/uid.html" .)) "-" }} {{ $mode := .Get "mode" | default "collapse" }} +{{ $separated := .Get "separated" | default false }} +{{ $isSeparated := or (eq $separated true) (eq $separated "true") }} -
+
{{- .Inner -}}
+{{ if not $isSeparated }} + +{{ end }} {{ if eq $mode "collapse" }}