mirror of
https://github.com/yrzam/yrzam-hugo-theme.git
synced 2025-10-19 09:32:20 +00:00
file shortcode
This commit is contained in:
parent
c854afa1ee
commit
6d786905ec
13
layouts/shortcodes/file.html
Normal file
13
layouts/shortcodes/file.html
Normal file
@ -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 -}}
|
Loading…
Reference in New Issue
Block a user