hugo-theme-relearn/layouts/partials/shortcodes/include.html

36 lines
1.3 KiB
HTML
Raw Normal View History

{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
2023-11-20 23:53:33 +00:00
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'include' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }}
{{- end }}
{{- $file := .file }}
2024-04-19 15:58:38 +00:00
{{- $content := "" }}
{{- with or
($page.Resources.Get $file)
(resources.Get $file)
}}
{{- $content = .Content }}
{{- else }}
{{- if (fileExists $file) }}
{{- $content = $file | readFile }}
{{- else }}
{{- if eq $page.Site.Params.include.errorlevel "warning" }}
{{- warnf "%q: file '%s' is not a resource nor accessible via file system" $page.File.Filename $file }}
{{- else if eq $page.Site.Params.include.errorlevel "error" }}
{{- errorf "%q: image '%s' is not a resource nor accessible via file system" $page.File.Filename $file }}
{{- end }}
{{- end }}
{{- end }}
{{- $hideFirstHeading := .hidefirstheading | default false }}
{{- if eq (printf "%T" $hideFirstHeading) "string" }}
{{- $hideFirstHeading = (eq $hideFirstHeading "true") }}
{{- end }}
2024-04-19 15:58:38 +00:00
{{- if $content }}
{{- if $hideFirstHeading }}<div class="include hide-first-heading">
{{ end }}
{{- with $page }}
2024-04-19 15:58:38 +00:00
{{- $content | safeHTML }}
{{- end }}
{{- if $hideFirstHeading }}</div>{{ end }}
{{- end }}