Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion layouts/shortcodes/ghcode.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
{{ $file := .Get 0 }}
{{ $params := .Get 1 }}
{{ $codeBlockId := printf "id-%x" (now.UnixNano) }}
{{ with resources.GetRemote $file }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ $lang := path.Ext $file | strings.TrimPrefix "." }}
{{ highlight .Content $lang $params }}
<div id="code-block-v1" data-mf="false">
{{ highlight .Content $lang $params }}
</div>

<div class="code-block" data-mf="true" style="display: none;">
{{- if and (ne $lang "") (ne $lang "none") -}}
<span class="code-type chroma">{{ $lang }}</span>
{{- end -}}
<div class="code-container chroma">
<button onclick="copyToClipBoard(this, {{ $codeBlockId }})" class="code-copy-button multi-line" type="button">Copy</button>
<div class="highlight-v2" id="{{ $codeBlockId }}">
{{ highlight .Content $lang $params }}
</div>
</div>
</div>
{{ end }}
{{ else }}
{{ errorf "Unable to load github content from %s from %q" $file .Position}}
Expand Down
Loading