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