Skip to content

Commit f4aa4d7

Browse files
authored
Document how accordion shortcodes work (#4390)
* Document how accordion shortcodes work Signed-off-by: Ian Maddaus <[email protected]> * Style testing Signed-off-by: Ian Maddaus <[email protected]> * Linting Signed-off-by: Ian Maddaus <[email protected]> --------- Signed-off-by: Ian Maddaus <[email protected]>
1 parent 27d6b8d commit f4aa4d7

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

content/style/shortcodes.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,72 @@ and `panel-id`/`panel-link` values must be unique HTML IDs on the page.
284284

285285
<!-- markdownlint-enable MD046 MD032 -->
286286

287+
## Accordion list
288+
289+
The Accordion shortcodes create a [Foundation Framework Accordion](https://get.foundation/sites/docs/accordion.html).
290+
291+
To add an accordion, wrap the `accordion-list` shortcode around as many `accordion-item` shortcodes as you want.
292+
293+
The following example creates an accordion list with a single list item:
294+
295+
```markdown
296+
{{</* accordion-list */>}}
297+
{{</* accordion-item accordion-title="List item description" */>}}
298+
Hello, world.
299+
{{</* /accordion-item */>}}
300+
{{</* /accordion-list */>}}
301+
```
302+
303+
### Parameters
304+
305+
The `accordion-list` shortcode has the following parameters:
306+
307+
`data-multi-expand`
308+
: Whether more than one list item can be displayed at the same time.
309+
310+
Default value: `false`
311+
312+
`data-allow-all-closed`
313+
: Whether all list items can be closed at the same time.
314+
315+
Default value: `false`
316+
317+
The `accordion-item` shortcode has the following parameters:
318+
319+
`accordion-title`
320+
: The accordion item title.
321+
322+
`is-active`
323+
: Whether the list item is active by default.
324+
325+
Default value: `false`
326+
327+
### Examples
328+
329+
The following example creates and accordion with two list items, the second is active by default, all items can be displayed at the same time, and both can be closed at the same time.
330+
331+
```markdown
332+
{{</* accordion-list data-multi-expand="true" data-allow-all-closed="true" */>}}
333+
{{</* accordion-item accordion-title="List item description" */>}}
334+
Hello, world.
335+
{{</* /accordion-item */>}}
336+
{{</* accordion-item accordion-title="Active item" is-active="true" */>}}
337+
This is active by default
338+
{{</* /accordion-item */>}}
339+
{{</* /accordion-list */>}}
340+
```
341+
342+
Which looks like this:
343+
344+
{{< accordion-list data-multi-expand="true" data-allow-all-closed="true" >}}
345+
{{< accordion-item accordion-title="List item description" >}}
346+
Hello, world.
347+
{{< /accordion-item >}}
348+
{{< accordion-item accordion-title="Active item" is-active="true" >}}
349+
This is active by default
350+
{{< /accordion-item >}}
351+
{{< /accordion-list >}}
352+
287353
## `highlight` shortcode
288354

289355
You can add code examples using the `highlight` shortcode.

content/style/test.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,59 @@ Checklists are an unordered list with a checkbox.
503503
504504
<!-- markdownlint-enable MD031 -->
505505
506+
### Accordions
507+
508+
Basic two item accordion:
509+
510+
{{< accordion-list data-multi-expand="true" data-allow-all-closed="true" >}}
511+
{{< accordion-item accordion-title="List item description" >}}
512+
Hello, world.
513+
{{< /accordion-item >}}
514+
{{< accordion-item accordion-title="Active item" is-active="true" >}}
515+
This is active by default
516+
{{< /accordion-item >}}
517+
{{< /accordion-list >}}
518+
519+
Accordion in an ordered list:
520+
521+
<!-- markdownlint-disable MD031 -->
522+
523+
These are procedures:
524+
525+
1. Do this.
526+
527+
1. Do that:
528+
529+
{{< accordion-list data-multi-expand="true" data-allow-all-closed="true" >}}
530+
{{< accordion-item accordion-title="Active item" is-active="true" >}}
531+
This is active by default
532+
533+
```json
534+
{
535+
"This": "is a sample json",
536+
"for": "markdown and Hugo testing."
537+
}
538+
```
539+
{{< /accordion-item >}}
540+
{{< /accordion-list >}}
541+
542+
Accordion in an unordered list:
543+
544+
This is a list:
545+
546+
- Some text
547+
548+
{{< accordion-list data-multi-expand="true" data-allow-all-closed="true" >}}
549+
{{< accordion-item accordion-title="List item description" >}}
550+
Hello, world.
551+
{{< /accordion-item >}}
552+
{{< accordion-item accordion-title="Active item" is-active="true" >}}
553+
This is active by default
554+
{{< /accordion-item >}}
555+
{{< /accordion-list >}}
556+
557+
<!-- markdownlint-enable MD031 -->
558+
506559
## Code
507560
508561
### Code blocks

0 commit comments

Comments
 (0)