Skip to content

Commit 2c98991

Browse files
committed
Ghcode: Fix rendering in latest version of hugo
New try syntax requires use of `else with .Value` before contents of resource can be used. See https://gohugo.io/functions/resources/getremote/
1 parent 88f2a47 commit 2c98991

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

layouts/shortcodes/ghcode.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
{{ with try (resources.GetRemote $file) }}
55
{{ with .Err }}
66
{{ errorf "%s" . }}
7-
{{ else }}
7+
{{ else with .Value }}
88
{{ $lang := path.Ext $file | strings.TrimPrefix "." }}
99
<div id="code-block-v1" data-mf="false">
10-
{{ highlight .Value $lang $params }}
10+
{{ highlight .Content $lang $params }}
1111
</div>
12-
12+
1313
<div class="code-block" data-mf="true" style="display: none;">
1414
{{- if and (ne $lang "") (ne $lang "none") -}}
1515
<span class="code-type chroma">{{ $lang }}</span>
1616
{{- end -}}
1717
<div class="code-container chroma">
1818
<button onclick="copyToClipBoard(this, {{ $codeBlockId }})" class="code-copy-button multi-line" type="button">Copy</button>
1919
<div class="highlight-v2" id="{{ $codeBlockId }}">
20-
{{ highlight .Value $lang $params }}
20+
{{ highlight .Content $lang $params }}
2121
</div>
2222
</div>
2323
</div>
2424
{{ end }}
2525
{{ else }}
2626
{{ errorf "Unable to load github content from %s from %q" $file .Position}}
27-
{{ end }}
27+
{{ end }}

0 commit comments

Comments
 (0)