Created
April 29, 2020 16:01
-
-
Save maxrodrigo/34996d1ea036555edb9b692d496fab19 to your computer and use it in GitHub Desktop.
Details disclosure and summary elements hugo shortcode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ .Scratch.Set "lastp" (sub (.Params | len) 1) }} | |
<details {{ if .Get 0 | eq "open"}} open {{ end }}> | |
<summary> | |
{{ .Get (.Scratch.Get "lastp") }} | |
</summary> | |
{{ .Inner | markdownify }} | |
</details> |
Thanks for your sharing your code! Here is my version using named parameters:
{{ $open := .Get "open" | default "false" }}
<details
{{ if eq $open "true"}}
open
{{ end }}
>
<summary>
{{ i18n "click_to_open" | default "Click to Open" }}
{{ with .Get "title" }}
{{ . | markdownify }}
{{ end }}
</summary>
{{ .Inner | markdownify }}
</details>
That's great!
Thanks!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! Thank you so much for publishing this code, it really helped me a lot.
Here is my slightly twisted version: