Extract gmi processed content into its own partial

This commit is contained in:
hedy 2024-04-11 08:51:07 +08:00
parent e7b575b071
commit f822e1444e
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
2 changed files with 12 additions and 12 deletions

View File

@ -0,0 +1,11 @@
{{- /*
* https://discourse.gohugo.io/t/using-renderstring-to-expand-shortcodes/40994/7
* support for using shortcodes in gemtext whilst having content as raw text.
*/ -}}
{{- $content := printf "~~~\n\n%s\n~~~" (trim (readFile (replace $.File.Path ".md" ".gmi")) "\n" | safeHTML) | .Page.RenderString | htmlUnescape }}
{{- $lines := split $content "\n" }}
{{- range $i, $_ := $lines }}
{{- if and $i (ne $i (sub (len $lines) 1)) }}
{{ . }}
{{- end -}}
{{- end -}}

View File

@ -18,18 +18,7 @@ Tag:
{{- if $index -}}, {{ end -}}{{ if (not $index) }}{{printf " "}}{{end}}{{ $tag | urlize }}{{- end -}}{{- end }}
{{- end }}
--
{{- /*
* https://discourse.gohugo.io/t/using-renderstring-to-expand-shortcodes/40994/7
* support for using shortcodes in gemtext whilst having content as raw text.
*/ -}}
{{- $content := printf "~~~\n%s~~~" (trim (readFile (replace $.File.Path ".md" ".gmi")) "\n" | safeHTML) | .Page.RenderString | htmlUnescape }}
{{- $lines := split $content "\n" }}
{{- range $i, $_ := $lines }}
{{- if and $i (ne $i (sub (len $lines) 1)) }}
{{ . }}
{{- end -}}
{{- end -}}
{{ partial "processed-content.gmi" . }}
--
Questions/comments: