mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
40 lines
No EOL
1.5 KiB
HTML
40 lines
No EOL
1.5 KiB
HTML
{{- $page := .page }}
|
|
{{- if and (not $page) .context }}
|
|
{{- $page = .context }}
|
|
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'include' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/#5-18-0" $page.File.Filename }}
|
|
{{- end }}
|
|
{{- $u := urls.Parse .file }}
|
|
{{- $path := strings.TrimPrefix "./" $u.Path }}
|
|
{{- $content := "" }}
|
|
{{- with or
|
|
($page.Page.GetPage $path)
|
|
($page.Page.GetPage (strings.TrimRight "/" $path))
|
|
($page.Page.Resources.Get $path)
|
|
(resources.Get $path)
|
|
}}
|
|
{{- $content = .Content }}
|
|
{{- else }}
|
|
{{- if (fileExists .file) }}
|
|
{{- $content = .file | readFile }}
|
|
{{- else }}
|
|
{{- $errorlevel := or $page.Params.include.errorlevel $page.Site.Params.include.errorlevel }}
|
|
{{- if eq $errorlevel "warning" }}
|
|
{{- warnf "%q: included file '%s' is not a page, resource or accessible via file system" $page.File.Filename .file }}
|
|
{{- else if eq $errorlevel "error" }}
|
|
{{- errorf "%q: included file '%s' is not a page, resource or 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 }}
|
|
{{- if $content }}
|
|
{{- if $hideFirstHeading }}<div class="include hide-first-heading">
|
|
|
|
{{ end }}
|
|
{{- with $page }}
|
|
{{- $content | safeHTML }}
|
|
{{- end }}
|
|
{{- if $hideFirstHeading }}</div>{{ end }}
|
|
{{- end }} |