aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-codeblock.html
blob: 85e60b215e6f5680aa57a2beaa4d66eb41e1ad6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{{- $caption := .Attributes.caption -}}
{{- $type    := .Type | default "text" -}}
{{- $options := .Attributes.options | default "default=1" -}}
{{- $hash    := print (truncate 8 "" (sha256 .Inner)) .Ordinal -}}
{{- $id      := print "code-block-" $hash -}}

<code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines=""{{ end }}>
  <header>
  <language-label>
    <a href="#{{ $id }}">{{ $type }}</a>
  </language-label>
    <button hidden="">
      {{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/copy.svg")) }}
      <span>Copy</span>
    </button>
  </header>
  {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" $hash) }}
</code-block>

{{ with $caption }}
  <footer>{{ . | markdownify }}</footer>
{{ end }}