Foswiki’s TwistyPlugin (https://foswiki.org/Extensions/TwistyPlugin) supports progressive disclosure (eg, hide and show links). Where should I look for something like this capability for Hugo?
You could incorporate a simple javascript for it:
A more hugo-ish way of doing it would be to use a shortcode to provide the div for hiding and showing, and either detect use of the shortcode, and load the javascript conditionally from <head>
or, maybe just load it at the top of the shortcode if it will work that way.
Use .HasShortcode
to detect it.
You could put this in your <head>
.
{{ if .HasShortCode "toggler" }}
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
{{ end }}
2 Likes