Skip to content

Commit aa3c60d

Browse files
committed
fix: Added styling to ghcode shortcode
1 parent 168d6e7 commit aa3c60d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

layouts/shortcodes/ghcode.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
{{ $file := .Get 0 }}
22
{{ $params := .Get 1 }}
3+
{{ $codeBlockId := printf "id-%x" (now.UnixNano) }}
34
{{ with resources.GetRemote $file }}
45
{{ with .Err }}
56
{{ errorf "%s" . }}
67
{{ else }}
78
{{ $lang := path.Ext $file | strings.TrimPrefix "." }}
8-
{{ highlight .Content $lang $params }}
9+
<div id="code-block-v1" data-mf="false">
10+
{{ highlight .Content $lang $params }}
11+
</div>
12+
13+
<div class="code-block" data-mf="true" style="display: none;">
14+
{{- if and (ne $lang "") (ne $lang "none") -}}
15+
<span class="code-type chroma">{{ $lang }}</span>
16+
{{- end -}}
17+
<div class="code-container chroma">
18+
<button onclick="copyToClipBoard(this, {{ $codeBlockId }})" class="code-copy-button multi-line" type="button">Copy</button>
19+
<div class="highlight-v2" id="{{ $codeBlockId }}">
20+
{{ highlight .Content $lang $params }}
21+
</div>
22+
</div>
23+
</div>
924
{{ end }}
1025
{{ else }}
1126
{{ errorf "Unable to load github content from %s from %q" $file .Position}}

0 commit comments

Comments
 (0)