2023-07-27 14:14:55 +00:00
|
|
|
{{- $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 }}
|
2023-07-27 14:14:55 +00:00
|
|
|
{{- end }}
|
2024-05-28 20:06:17 +00:00
|
|
|
{{- $u := urls.Parse .file }}
|
|
|
|
{{- $path := strings.TrimPrefix "./" $u.Path }}
|
2024-04-19 15:58:38 +00:00
|
|
|
{{- $content := "" }}
|
|
|
|
{{- with or
|
2024-05-28 20:06:17 +00:00
|
|
|
($page.Page.GetPage $path)
|
|
|
|
($page.Page.GetPage (strings.TrimRight "/" $path))
|
|
|
|
($page.Page.Resources.Get $path)
|
|
|
|
(resources.Get $path)
|
2024-04-19 15:58:38 +00:00
|
|
|
}}
|
|
|
|
{{- $content = .Content }}
|
|
|
|
{{- else }}
|
2024-05-28 20:06:17 +00:00
|
|
|
{{- if (fileExists .file) }}
|
|
|
|
{{- $content = .file | readFile }}
|
2024-04-19 15:58:38 +00:00
|
|
|
{{- else }}
|
|
|
|
{{- if eq $page.Site.Params.include.errorlevel "warning" }}
|
2024-05-28 20:06:17 +00:00
|
|
|
{{- warnf "%q: included file '%s' is not a page, resource or accessible via file system" $page.File.Filename .file }}
|
2024-04-19 15:58:38 +00:00
|
|
|
{{- else if eq $page.Site.Params.include.errorlevel "error" }}
|
2024-05-28 20:06:17 +00:00
|
|
|
{{- errorf "%q: included file '%s' is not a page, resource or accessible via file system" $page.File.Filename .file }}
|
2024-04-19 15:58:38 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2022-06-23 11:22:04 +00:00
|
|
|
{{- $hideFirstHeading := .hidefirstheading | default false }}
|
|
|
|
{{- if eq (printf "%T" $hideFirstHeading) "string" }}
|
|
|
|
{{- $hideFirstHeading = (eq $hideFirstHeading "true") }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- end }}
|
2024-04-19 15:58:38 +00:00
|
|
|
{{- if $content }}
|
2023-11-16 21:50:35 +00:00
|
|
|
{{- if $hideFirstHeading }}<div class="include hide-first-heading">
|
2022-06-22 18:32:18 +00:00
|
|
|
|
2023-11-16 21:50:35 +00:00
|
|
|
{{ end }}
|
|
|
|
{{- with $page }}
|
2024-04-19 15:58:38 +00:00
|
|
|
{{- $content | safeHTML }}
|
2023-02-19 22:09:51 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- if $hideFirstHeading }}</div>{{ end }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- end }}
|