adding partials for <include>

This commit is contained in:
2026-03-28 02:00:49 +00:00
parent 077aa4b523
commit 319153c8c2
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
{{/*
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
*/}}
{{- $path := .path -}}
{{- $context := .context -}}
{{- if fileExists $path -}}
{{- $content := readFile $path -}}
{{- $context.RenderString $content -}}
{{- else -}}
{{- warnf "Include file not found: %s" $path -}}
<p class="text-red-500 font-bold">[Include Error: File "{{ $path }}" not found]</p>
{{- end -}}

View File

@@ -0,0 +1,10 @@
{{- $path := .Get 0 -}}
{{- if not $path -}}
{{- $path = .Get "src" -}}
{{- end -}}
{{- if $path -}}
{{- partial "include.html" (dict "context" .Page "path" $path) -}}
{{- else -}}
{{- warnf "Shortcode 'include' called without path or src attribute." -}}
<p class="text-red-500 font-bold">[Include Error: No path provided]</p>
{{- end -}}