test include again
This commit is contained in:
@@ -1,27 +1,39 @@
|
||||
{{/*
|
||||
Partial: include.html
|
||||
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 -}}
|
||||
{{- $context := .context -}}
|
||||
|
||||
{{/* Map absolute private paths to the relative content mount point */}}
|
||||
{{- $path = replace $path "/srv/docs/private/" "private/" -}}
|
||||
|
||||
{{/* Remove leading slash if any (GetPage prefers relative-to-content paths) */}}
|
||||
{{- $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 -}}
|
||||
{{- 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 -}}
|
||||
{{- $p.Content -}}
|
||||
{{- else -}}
|
||||
{{/* Fallback to readFile for non-page files */}}
|
||||
{{- if fileExists $path -}}
|
||||
{{- $content := readFile $path -}}
|
||||
{{/* Fallback to readFile - check multiple path variations */}}
|
||||
{{- $found := false -}}
|
||||
{{- $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 */}}
|
||||
{{- if (findRE "^---" $content) -}}
|
||||
{{- $content = replaceRE "^(?s)---.*?---[\\r\\n]*" "" $content -}}
|
||||
|
||||
Reference in New Issue
Block a user