Add shortcode for content snippets
This commit is contained in:
parent
e4ff96aee2
commit
4784466e69
1 changed files with 14 additions and 0 deletions
14
layouts/shortcodes/snippet.html
Normal file
14
layouts/shortcodes/snippet.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{{- $asset := "" }}
|
||||
{{- with (.Get 0) }}
|
||||
{{- $asset = . }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode requires a single positional parameter; the relative path to a file in the assets directory. See %s" .Name .Position}}
|
||||
{{- end }}
|
||||
|
||||
{{- $r := "" }}
|
||||
{{- with resources.Get $asset }}
|
||||
{{- $r = . }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to find %q. See %s" .Name $asset .Position}}
|
||||
{{- end }}
|
||||
{{- $r.Content | .Page.RenderString -}}
|
Loading…
Reference in a new issue