test include again

This commit is contained in:
2026-03-28 04:59:39 +00:00
parent f6f8e2fe81
commit 8a57cbf8a5

View File

@@ -1,27 +1,39 @@
{{/* {{/*
Partial: include.html Partial: include.html
Handles including external Markdown files and rendering them. Handles including external Markdown files and rendering them.
Parameters:
- context: The Page context (required for RenderString/GetPage)
- path: Path to the file, relative to the project root or content root
*/}} */}}
{{- $path := .path -}} {{- $path := .path -}}
{{- $context := .context -}} {{- $context := .context -}}
{{/* Map absolute private paths to the relative content mount point */}} {{/* Map absolute private paths to the relative content mount point */}}
{{- $path = replace $path "/srv/docs/private/" "private/" -}} {{- $path = replace $path "/srv/docs/private/" "private/" -}}
{{/* Remove leading slash if any (GetPage prefers relative-to-content paths) */}}
{{- $path = trim $path "/" -}} {{- $path = trim $path "/" -}}
{{/* Try to get as a Page first (supports mounts and already handles frontmatter) */}} {{/* Try multiple variations to find the Page */}}
{{- $p := $context.Site.GetPage $path -}} {{- $p := $context.Site.GetPage $path -}}
{{- if not $p }}{{ $p = $context.Site.GetPage (printf "/%s" $path) }}{{ end -}}
{{- if not $p }}{{ $p = $context.Site.GetPage (strings.TrimSuffix ".md" $path) }}{{ end -}}
{{- if not $p }}{{ $p = $context.Site.GetPage (printf "/%s" (strings.TrimSuffix ".md" $path)) }}{{ end -}}
{{- if not $p }}{{ $p = $context.Site.GetPage (lower $path) }}{{ end -}}
{{- if not $p }}{{ $p = $context.Site.GetPage (lower (strings.TrimSuffix ".md" $path)) }}{{ end -}}
{{- if not $p }}{{ $p = $context.Site.GetPage (printf "/%s" (lower (strings.TrimSuffix ".md" $path))) }}{{ end -}}
{{- if $p -}} {{- if $p -}}
{{- $p.Content -}} {{- $p.Content -}}
{{- else -}} {{- else -}}
{{/* Fallback to readFile for non-page files */}} {{/* Fallback to readFile - check multiple path variations */}}
{{- if fileExists $path -}} {{- $found := false -}}
{{- $content := readFile $path -}} {{- $content := "" -}}
{{- $pathsToTry := slice $path (printf "content/%s" $path) (printf "/%s" $path) -}}
{{- range $pathsToTry -}}
{{- if and (not $found) (fileExists .) -}}
{{- $content = readFile . -}}
{{- $found = true -}}
{{- end -}}
{{- end -}}
{{- if $found -}}
{{/* Strip frontmatter if it exists */}} {{/* Strip frontmatter if it exists */}}
{{- if (findRE "^---" $content) -}} {{- if (findRE "^---" $content) -}}
{{- $content = replaceRE "^(?s)---.*?---[\\r\\n]*" "" $content -}} {{- $content = replaceRE "^(?s)---.*?---[\\r\\n]*" "" $content -}}