diff --git a/config/_default/hugo.toml b/config/_default/hugo.toml index d0af0c7..8c9257d 100644 --- a/config/_default/hugo.toml +++ b/config/_default/hugo.toml @@ -41,4 +41,11 @@ enableGitInfo = true [markup.tableOfContents] endLevel = 3 ordered = false - startLevel = 2 \ No newline at end of file + startLevel = 2 +[module] + [[module.mounts]] + source = "content" + target = "content" + [[module.mounts]] + source = "/srv/docs/private" + target = "content/private" diff --git a/layouts/partials/include.html b/layouts/partials/include.html index 5633f33..a4202c2 100644 --- a/layouts/partials/include.html +++ b/layouts/partials/include.html @@ -2,16 +2,27 @@ Partial: include.html Handles including external Markdown files and rendering them. Parameters: - - context: The Page context (required for RenderString) - - path: Path to the file, relative to the project root + - 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 -}} -{{- if fileExists $path -}} - {{- $content := readFile $path -}} - {{- $context.RenderString $content -}} +{{/* Try to get as a Page first (supports mounts and already handles frontmatter) */}} +{{- $p := $context.Site.GetPage $path -}} +{{- if $p -}} + {{- $p.Content -}} {{- else -}} - {{- warnf "Include file not found: %s" $path -}} -
[Include Error: File "{{ $path }}" not found]
+ {{/* Fallback to readFile for non-page files */}} + {{- if fileExists $path -}} + {{- $content := readFile $path -}} + {{/* Strip frontmatter if it exists */}} + {{- if (findRE "^---" $content) -}} + {{- $content = replaceRE "^(?s)---.*?---[\\r\\n]*" "" $content -}} + {{- end -}} + {{- $context.RenderString $content -}} + {{- else -}} + {{- warnf "Include file not found: %s" $path -}} +[Include Error: File "{{ $path }}" not found]
+ {{- end -}} {{- end -}}