2024-04-10 15:12:00

This commit is contained in:
Kai Kimera 2024-04-10 15:12:00 +00:00
parent 3105c789a3
commit 8ef6c59369
2 changed files with 41 additions and 1 deletions

40
layouts/shortcodes/code.html Executable file
View file

@ -0,0 +1,40 @@
{{- /*
Code block with syntax highlighting.
@param {string} (positional parameter 0) Syntax highlighting.
@returns {template.HTML}
@examples
{{< code >}}
make && make install && make basic-pbx && make config && ldconfig
{{< /code >}}
{{< code "bash" >}}
make && make install && make basic-pbx && make config && ldconfig
{{< /code >}}
*/ -}}
{{ $lang := (.Get 0) }}
{{ $cp := ((printf "clipboard-%s" (delimit (shuffle (seq 11 99)) "")) | md5) }}
<div class="shortcode mb-3 shortcode-codeblock shortcode-codeblock-{{ (.Ordinal) }} {{ with ($lang) }}shortcode-codeblock-{{ . }}{{ end }}">
<div class="d-flex overflow-hidden">
<div class="flex-grow-1 rounded overflow-hidden" id="cp-{{ ($cp) }}">
{{ if ($lang) }}{{ $lang = (printf "class='language-%s'" ($lang)) }}{{ end }}
<pre><code {{ (($lang) | safeHTMLAttr) }}>{{ (trim (.Inner) "\n\r") }}</code></pre>
</div>
<div class="flex-shrink-0">
<ul class="list-inline mb-0">
<li class="list-inline-item" data-bs-tooltip data-bs-title='{{ (i18n "copy") }}'>
<a class="text-body" href="#"
data-fn="clipboard preventDefault" data-clipboard-target="#cp-{{ ($cp) }}"
role="button" aria-label='{{ (i18n "copy") }}'>
<i class="fas fa-copy fa-fw"></i>
</a>
</li>
</ul>
</div>
</div>
</div>

View file

@ -5,7 +5,7 @@
@examples
{{< mention "KitsuneSolar" >}}
{{< mention "username" >}}
*/ -}}
{{- if (.Get 0) -}}