aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/generate-feeds.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/partials/generate-feeds.html')
-rw-r--r--themes/default/layouts/partials/generate-feeds.html46
1 files changed, 18 insertions, 28 deletions
diff --git a/themes/default/layouts/partials/generate-feeds.html b/themes/default/layouts/partials/generate-feeds.html
index d94e39a..02164f9 100644
--- a/themes/default/layouts/partials/generate-feeds.html
+++ b/themes/default/layouts/partials/generate-feeds.html
@@ -126,15 +126,27 @@
{{- end -}}
- {{- /* Common time zone typos. */ -}}
- {{- $date = strings.Replace $date "G6T" "GST" -}}
+ {{- $sourceDomain := ($sourceLink | plainify | htmlUnescape | urls.Parse).Host -}}
+
+ {{- /* Replace invalid time zones. */ -}}
+ {{- $date = replaceRE "G[0-9]+T" "UTC" $date -}}
{{- /* If missing seconds split and try again. */ -}}
{{- if lt (len (split $date ":")) 3 -}}
{{- $date = delimit (first 3 (after 1 (split $date " "))) " " -}}
{{- end -}}
- {{
+ {{- /* Try to complete enclosure relative links. */ -}}
+ {{- if not ($enclosure | urls.Parse).Host -}}
+ {{- $enclosure = print "http://" $sourceDomain $link -}}
+ {{- end -}}
+
+ {{- /* Try to complete link relative links. */ -}}
+ {{- if not ($link | urls.Parse).Host -}}
+ {{- $link = print "http://" $sourceDomain $link -}}
+ {{- end -}}
+
+ {{-
$feeds = $feeds | append (dict
"FeedContent" ($content | plainify | htmlUnescape)
"FeedContentShort" (delimit (first 2 (split ($content | plainify | htmlUnescape) "\n")) " " | truncate 250)
@@ -147,7 +159,7 @@
"FeedLink" ($link | plainify | htmlUnescape)
"FeedName" (delimit ((delimit (first 2 (split ($sourceTitle | plainify | htmlUnescape) " ")) " ") | findRE "^([^.|?|!|\n|\"|]+)") " " | replaceRE "[^a-zA-Z ]" "")
"FeedSourceDescription" ($sourceDescription | plainify | htmlUnescape)
- "FeedSourceDomain" (($sourceLink | plainify | htmlUnescape | urls.Parse).Host)
+ "FeedSourceDomain" ($sourceDomain)
"FeedSourceLink" ($sourceLink | plainify | htmlUnescape)
"FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape)
"FeedTitle" ($title | plainify | htmlUnescape)
@@ -197,28 +209,6 @@
{{- $content = .FeedTitle -}}
{{- end -}}
- {{- $link := .FeedLink -}}
- {{- $enclosure := .FeedEnclosure -}}
- {{- if or
- (in .FeedLink ".apng")
- (in .FeedLink ".avif")
- (in .FeedLink ".gif")
- (in .FeedLink ".jfif")
- (in .FeedLink ".jpeg")
- (in .FeedLink ".jpg")
- (in .FeedLink ".pjp")
- (in .FeedLink ".pjpeg")
- (in .FeedLink ".png")
- (in .FeedLink ".svg")
- (in .FeedLink ".webp")
- -}}
- {{- if (.Feedlink | urls.Parse).Host -}}
- {{- else -}}
- {{- $enclosure = print "http://" .FeedSourceDomain .FeedLink -}}
- {{- $link = $enclosure -}}
- {{- end -}}
- {{- end -}}
-
{{- $markdown := resources.ExecuteAsTemplate
$path
(dict
@@ -227,9 +217,9 @@
"date" .FeedDateTime
"description" .FeedSourceTitle
"domain" .FeedSourceDomain
- "enclosure" $enclosure
+ "enclosure" .FeedEnclosure
"image" $imageSource
- "link" $link
+ "link" .FeedLink
"name" .FeedName
"raw" (strings.TrimLeft "/" $path)
"self" (print $author.user "/feeds/" $name "/")