expandable.html 1.1 KB

12345678910111213141516171819202122232425
  1. <div class="expandable-section">
  2. {{ if .Get "level" }}
  3. <h{{ .Get "level" }}>
  4. {{ end }}
  5. {{/* 1. Get the md5 hash of the expandable inner text */}}
  6. {{/* 2. Split the hash string into an array */}}
  7. {{/* 3. Shuffle the array */}}
  8. {{/* 4. Convert the array back into a string */}}
  9. {{ $random := delimit (shuffle (split (md5 .Inner) "" )) "" }}
  10. <button aria-expanded="{{ with .Get "open" }}true{{ else }}false{{ end }}" data-expands="js-expandable-{{ $random }}">
  11. <span class="expandable-label">{{ .Get "label" | default "More info" }}</span>
  12. <svg aria-hidden="true" focusable="false" viewBox="0 0 70.866142 70.866141">
  13. <g transform="translate(0 -981.5)">
  14. <rect style="stroke-width:0;fill:currentColor" ry="5" height="60" width="9.8985" y="987.36" x="30.051" class="up-strut" />
  15. <rect style="stroke-width:0;fill:currentColor" ry="5" height="10" width="60" y="1012.4" x="5"/>
  16. </g>
  17. </svg>
  18. </button>
  19. {{ if .Get "level" }}
  20. </h{{ .Get "level"}}>
  21. {{ end }}
  22. <div id="js-expandable-{{ $random }}" {{ with .Get "open" | not }}hidden{{ end }}>
  23. {{ .Inner | markdownify }}
  24. </div>
  25. </div>