Files
hugo/layouts/shortcodes/code.html
T
Bjørn Erik Pedersen bdf97b7b45 Add new theme
2025-02-11 16:30:05 +01:00

31 lines
876 B
HTML

{{ $codeLang := "go-html-template" }}
<div
x-data
class="shortcode-code font-mono not-prose relative bg-gray-200 dark:bg-blue-900 text-gray-500 p-[1px] dark:text-gray-400 mt-6 mb-8">
{{- with .Get "file" -}}
<div class="san-serif text-sm inline-block leading-none pl-2 py-3">
{{ . }}
</div>
{{- end -}}
{{ if ne (.Get "copy") "false" }}
<svg
class="absolute right-0 top-2 pr-3 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-10"
@click="$copy($refs.code)">
<use href="#icon--copy"></use>
</svg>
{{ end }}
<div class="" x-ref="code">
{{ $inner := trim .Inner "\n" | safeHTML }}
{{ if .Get "nocode" }}
{{ $inner }}
{{ else }}
{{ with $codeLang }}
{{ highlight $inner . "" }}
{{ else }}
<pre><code>{{ $inner }}</code></pre>
{{ end }}
{{ end }}
</div>
</div>