Minify HTML content in feed XML

This commit is contained in:
Will Faught
2025-03-03 18:39:01 -08:00
parent 5005cda64c
commit 1621f43848
3 changed files with 12 additions and 2 deletions

View File

@@ -107,7 +107,7 @@
{{ range $subpage := $subpages }}
{{ if not (.Param "paige.exclude_feeds") }}
<entry>
{{ $content := .Content }}
{{ $content := partial "paige/func-minify.html" (dict "content" .Content) }}
{{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }}
{{ $id := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") .RelPermalink }}
{{ $lastmod := .Lastmod.Format $date }}

View File

@@ -97,7 +97,7 @@
<item>
{{ $author := "" }}
{{ $authors := partial "paige/func-authors.html" . }}
{{ $description := .Content }}
{{ $description := partial "paige/func-minify.html" (dict "content" .Content) }}
{{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }}
{{ $guid := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") (cond (.Params.id | not) .RelPermalink .Params.id) }}
{{ $published := .PublishDate.Format $date }}

View File

@@ -0,0 +1,10 @@
{{ $params := . }}
{{ $content := $params.content }}
{{ $extension := $params.extension | default "html" }}
{{ $path := print (sha1 $content) ".paige.tmp." $extension }}
{{ $result := (resources.FromString $path $content | minify).Content }}
{{ return $result }}