Files
hugo-theme-terminal/layouts/shortcodes/code.html
2025-02-28 15:14:45 +01:00

17 lines
737 B
HTML

{{ $id := delimit (shuffle (seq 1 9)) "" }}
{{ $open := .Get "open" }}
{{ $lang := .Get "language" }}
{{- if $lang -}}
<details class="collapsable-code" title="Click to interact" {{ if eq $open "true" -}} open {{- end }}>
<summary>
<span class="collapsable-code__language">{{ $lang }}</span>
{{- if .Get "title" }}<span class="collapsable-code__title">{{ .Get "title" | markdownify }}</span>{{ end -}}
</summary>
{{ $trInner := trim .Inner "\n" }}
{{- transform.Highlight $trInner ($lang) -}}
</details>
{{ else }}
{{ errorf "If you want to use the \"collapsable code\" shortcode, you need to pass a mandatory \"language\" param. The issue occured in %q (%q)" .Page.File .Page.Permalink }}
{{- end -}}