mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2025-07-01 17:47:29 -05:00
Use resources to power the include shortcode
https://github.com/gohugoio/hugo/issues/13823#issuecomment-3015270202 Then I can just create unrendered pages for snippets. It fixes all the markdown rendering related woes.
This commit is contained in:
@ -1,20 +1,14 @@
|
|||||||
{{ $path := "" }}
|
{{/* https://github.com/gohugoio/hugo/issues/13823#issuecomment-3015270202 */}}
|
||||||
{{ $markdown := false }}
|
{{ with .Get 0 }}
|
||||||
{{ if .IsNamedParams }}
|
{{ with $.Page.GetPage . }}
|
||||||
{{ $path = .Get "path" }}
|
{{- .RenderShortcodes }}
|
||||||
{{ with .Get "markdown" }}
|
{{ else with $.Page.Resources.Get . }}
|
||||||
{{ $markdown = . }}
|
{{- .RenderShortcodes }}
|
||||||
{{ end }}
|
{{ else with resources.Get . }}
|
||||||
{{ else }}
|
{{- .Content }}
|
||||||
{{ $path = .Get 0 }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ with ($path | readFile) }}
|
|
||||||
{{ if $markdown }}
|
|
||||||
{{ $path | readFile | $.Page.RenderString (dict "display" "block") }}
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $path | readFile }}
|
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ errorf "file not found: %s" $path }}
|
{{ errorf "The %q shortcode requires a positional parameter indicating the logical path of the file to include. See %s" .Name .Position }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Reference in New Issue
Block a user