aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-codeblock.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-codeblock.html')
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock.html28
1 files changed, 17 insertions, 11 deletions
diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html
index f5c0e13..ab9a786 100644
--- a/themes/default/layouts/_default/_markup/render-codeblock.html
+++ b/themes/default/layouts/_default/_markup/render-codeblock.html
@@ -1,19 +1,25 @@
-{{ $options := .Attributes.options | default "default=1" }}
-{{ $caption := .Attributes.caption }}
+{{- $caption := .Attributes.caption -}}
+{{- $type := .Type | default "text" -}}
+{{- $options := .Attributes.options | default "default=1" -}}
+{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) .Ordinal -}}
+{{- $id := print "code-block:" $hash | safeURL -}}
+{{- $highlight := highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) -}}
-<code-block {{ if in (lower $options) "linenos" }}data-lines{{ end }}>
+<code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines=""{{ end }}>
<header>
<language-label>
- {{ .Type }}
+ <a href="#{{ $id }}">{{ $type }}</a>
</language-label>
- <button>
- {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/copy.svg")) }}
- <span>Copy</span>
- </button>
</header>
- {{ highlight .Inner .Type (print $options ",lineAnchors=" "code-" (truncate 7 "" (md5 .Inner))) }}
+ <code-content contenteditable="true" spellcheck="false">
+ {{- replace $highlight
+ `class="lnlinks"`
+ `contenteditable="false" class="lnlinks"`
+ | safeHTML
+ -}}
+ </code-content>
</code-block>
-{{ with $caption }}
+{{- with $caption -}}
<footer>{{ . | markdownify }}</footer>
-{{ end }}
+{{- end -}}