1. Restored resume.md: Left exactly as it was.
2. Configured hugo.toml Mounts: I mounted /srv/configs into the virtual assets namespace. This
securely gives Hugo access to those files as raw static resources.
3. Updated include Partial: I rewrote the shortcode partial (layouts/partials/include.html) to:
* Intercept absolute paths starting with /srv/configs/, map them to configs/..., and retrieve
their raw text content using resources.Get.
* Intercept paths starting with /srv/docs/private/, look them up as a Page, and use .RawContent
instead of .Content (which prevents Hugo from wrapping your Markdown in HTML <p> tags when
injecting it into your code blocks).
* Strip any YAML frontmatter from the raw content using a regex replaceRE block.
45 lines
1.4 KiB
HTML
45 lines
1.4 KiB
HTML
{{- $path := .path -}}
|
|
{{- $content := "" -}}
|
|
{{- $found := false -}}
|
|
|
|
{{- /* Handle /srv/configs/ mapping to assets mount (mounted at assets/configs) */ -}}
|
|
{{- if strings.HasPrefix $path "/srv/configs/" -}}
|
|
{{- $assetPath := strings.TrimPrefix "/srv/" $path -}}
|
|
{{- $res := resources.Get $assetPath -}}
|
|
{{- if $res -}}
|
|
{{- $content = $res.Content -}}
|
|
{{- $found = true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- /* Handle /srv/docs/private/ mapping to content mount */ -}}
|
|
{{- if not $found -}}
|
|
{{- if strings.HasPrefix $path "/srv/docs/private/" -}}
|
|
{{- $pagePath := strings.TrimPrefix "/srv/docs/private/" $path -}}
|
|
{{- $p := site.GetPage (printf "private/%s" $pagePath) -}}
|
|
{{- if $p -}}
|
|
{{- $content = $p.RawContent -}}
|
|
{{- $found = true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- /* Handle relative or other paths by direct Page lookup */ -}}
|
|
{{- if not $found -}}
|
|
{{- $p := site.GetPage $path -}}
|
|
{{- if $p -}}
|
|
{{- $content = $p.RawContent -}}
|
|
{{- $found = true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if $found -}}
|
|
{{- /* Fallback manual frontmatter strip for assets that might have it */ -}}
|
|
{{- if findRE "^---" $content -}}
|
|
{{- $content = replaceRE "^(?s)---[\\s\\S]*?---[\\r\\n]*" "" $content -}}
|
|
{{- end -}}
|
|
{{- $content | safeHTML -}}
|
|
{{- else -}}
|
|
{{- warnf "WARN Include file not found: %s" $path -}}
|
|
{{- end -}}
|