Skip to content

Commit 9836d10

Browse files
author
Tim Bannister
committed
Add support for <details> via shortcode
1 parent a0020d3 commit 9836d10

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

assets/scss/_documentation.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,21 @@ body.td-home #deprecation-warning {
238238
margin-right: auto;
239239
}
240240

241+
// <details> shortcode
242+
243+
details > summary {
244+
margin-bottom: 1em;
245+
color: $primary;
246+
background: transparent;
247+
}
248+
249+
details:not([open]) > summary:after {
250+
content: '';
251+
display: inline-block;
252+
}
253+
254+
// glossary
255+
241256
body.glossary {
242257
main {
243258
ul.glossary-terms > li {

content/en/docs/contribute/style/hugo-shortcodes/index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,34 @@ Add the shortcode:
370370

371371
before the item, or just below the heading for the specific item.
372372

373+
## Details
374+
375+
You can render a `<details>` HTML element using a shortcode:
376+
377+
```markdown
378+
{{</* details summary="More about widgets" */>}}
379+
The frobnicator extension API implements _widgets_ using example running text.
380+
381+
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur,
382+
adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et
383+
dolore magnam aliquam quaerat voluptatem.
384+
{{</* /details */>}}
385+
```
386+
387+
This renders as:
388+
{{< details summary="More about widgets" >}}
389+
The frobnicator extension API implements _widgets_ using example running text.
390+
391+
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur,
392+
adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et
393+
dolore magnam aliquam quaerat voluptatem.
394+
{{< /details >}}
395+
396+
{{< note >}}
397+
Use this shortcode sparingly; it is usually best to have all of the text directly shown
398+
to readers.
399+
{{< /note >}}
400+
373401
## Version strings
374402

375403
To generate a version string for inclusion in the documentation, you can choose from

layouts/shortcodes/details.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- $summary := "" -}}
2+
{{- if .IsNamedParams -}}
3+
{{- $summary = .Get "summary" -}}
4+
{{- end -}}
5+
<details>
6+
{{- if ne $summary "" -}}
7+
<summary>{{ $summary }}</summary>
8+
{{- end -}}
9+
<div class="details-inner">
10+
{{ .Inner | markdownify }}
11+
</div>
12+
</details>

0 commit comments

Comments
 (0)