Skip to content

Commit 44faefc

Browse files
committed
add details tag with full example to code snippets
1 parent ad4bd2e commit 44faefc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

website_and_docs/layouts/shortcodes/gh-codeblock.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
{{ $fullPath := .Get "path" }}
2323
{{ $path := index (split $fullPath "#") 0 }}
24+
{{ $hasFragment := in $fullPath "#" }}
2425

2526
{{ $apiUrl := printf "%s/%s/%s/contents%s?ref=%s" $apiBaseUrl $org $repo $path $branch }}
2627
{{ $webUrl := printf "%s/%s/%s/blob/%s/%s" $webBaseUrl $org $repo $branch $fullPath }}
@@ -50,6 +51,13 @@
5051

5152
{{ highlight $codeSnippet $language }}
5253

54+
{{ if $hasFragment }}
55+
<details class="mt-2">
56+
<summary>Show full example</summary>
57+
<div class="pt-2">{{ highlight $content $language }}</div>
58+
</details>
59+
{{ end }}
60+
5361
<div class="text-end pb-2">
5462
<a href="{{- $webUrl -}}" target="_blank">
5563
<i class="fas fa-external-link-alt pl-2"></i>
@@ -58,6 +66,4 @@
5866
</div>
5967
{{ else }}
6068
{{ partial "github-content.html" }}
61-
{{ end }}
62-
63-
69+
{{ end }}

0 commit comments

Comments
 (0)