hextra_mirror/layouts/_default/_markup/render-codeblock.html

26 lines
1.3 KiB
HTML
Raw Normal View History

{{- $class := .Attributes.class | default "" -}}
{{- $filename := .Attributes.filename | default "" -}}
{{- $lang := .Attributes.lang | default .Type -}}
{{- $copyCode := (T "copyCode") | default "Copy code" -}}
<div class="code-block hx-relative hx-mt-6 first:hx-mt-0 group/code">
{{- if $filename -}}
<div class="filename">{{ $filename }}</div>
{{- end -}}
{{- if transform.CanHighlight $lang -}}
<div>{{- highlight .Inner $lang .Options -}}</div>
{{- else -}}
<pre><code>{{ .Inner }}</code></pre>
{{- end -}}
<div class="hx-opacity-0 hx-transition group-hover/code:hx-opacity-100 hx-flex hx-gap-1 hx-absolute hx-m-[11px] hx-right-0 {{ if $filename }}hx-top-8{{ else }}hx-top-0{{ end }}">
<button
class="code-copy-btn group/copybtn hx-transition-all active:hx-opacity-50 hx-bg-primary-700/5 hx-border hx-border-black/5 hx-text-gray-600 hover:hx-text-gray-900 hx-rounded-md hx-p-1.5 dark:hx-bg-primary-300/10 dark:hx-border-white/10 dark:hx-text-gray-400 dark:hover:hx-text-gray-50"
title="{{ $copyCode }}"
>
<div class="copy-icon group-[.copied]/copybtn:hx-hidden hx-pointer-events-none hx-h-4 hx-w-4"></div>
<div class="success-icon hx-hidden group-[.copied]/copybtn:hx-block hx-pointer-events-none hx-h-4 hx-w-4"></div>
</button>
</div>
</div>