diff --git a/layouts/partials/include.html b/layouts/partials/include.html new file mode 100644 index 0000000..5633f33 --- /dev/null +++ b/layouts/partials/include.html @@ -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 -}} +
[Include Error: File "{{ $path }}" not found]
+{{- end -}} diff --git a/layouts/shortcodes/include.html b/layouts/shortcodes/include.html new file mode 100644 index 0000000..d56ac5e --- /dev/null +++ b/layouts/shortcodes/include.html @@ -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." -}} +[Include Error: No path provided]
+{{- end -}}