From 6d786905ec65d9991e5a4ab356f38ec1e14f8b12 Mon Sep 17 00:00:00 2001 From: Yuri Zamyatin Date: Sun, 12 Oct 2025 22:46:28 +0000 Subject: [PATCH] file shortcode --- layouts/shortcodes/file.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 layouts/shortcodes/file.html diff --git a/layouts/shortcodes/file.html b/layouts/shortcodes/file.html new file mode 100644 index 0000000..00b0328 --- /dev/null +++ b/layouts/shortcodes/file.html @@ -0,0 +1,13 @@ +{{- if gt ( len .Params ) 1 -}} + {{- $.Scratch.Set "format" ( .Get 1 ) -}} +{{- else -}} + {{- $splits := ( split ( .Get 0 ) "." ) -}} + {{- $splitsLength := ( len $splits ) -}} + {{- $format := ( index $splits ( sub $splitsLength 1 ) ) -}} + {{- $.Scratch.Set "format" $format -}} +{{- end -}} + +{{- $file := ( .Get 0 ) -}} +{{- $format := ( $.Scratch.Get "format" ) -}} + +{{- ( print "```" $format "\n" ( readFile $file ) "\n" "```" ) | markdownify -}}