aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/feeds-generate.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/partials/feeds-generate.html')
-rw-r--r--themes/default/layouts/partials/feeds-generate.html41
1 files changed, 35 insertions, 6 deletions
diff --git a/themes/default/layouts/partials/feeds-generate.html b/themes/default/layouts/partials/feeds-generate.html
index ab60435..068ad40 100644
--- a/themes/default/layouts/partials/feeds-generate.html
+++ b/themes/default/layouts/partials/feeds-generate.html
@@ -22,19 +22,23 @@
{{- $sourceLink := "https://example.com/" -}}
{{- $sourceDescription := "No source description found." -}}
{{- $date := now.Format "2006-01-02T15:04:05Z" -}}
+ {{- $enclosure := "" -}}
{{ with .channel -}}
- {{ if reflect.IsMap (index .link 0) -}}
- {{ $sourceLink = index (index .link 0) "-href" -}}
- {{ else -}}
- {{ $sourceLink = index .link 0 -}}
- {{ end -}}
+ {{ if reflect.IsSlice .link -}}
+ {{ if reflect.IsMap (index .link 0) -}}
+ {{ $sourceLink = index (index .link 0) "-href" -}}
+ {{ else -}}
+ {{ $sourceLink = index .link 0 -}}
+ {{ end -}}
+ {{ else }}
+ {{ $sourceLink = .link -}}
+ {{ end }}
{{ $sourceTitle = .title -}}
{{ $sourceDescription = .description -}}
-
{{ if reflect.IsMap .item -}}
{{ with .item }}
{{ $title = index . "title" }}
@@ -48,6 +52,9 @@
{{ $title = .title -}}
{{ $link = .link -}}
{{ $date = .pubDate -}}
+ {{ with .enclosure }}
+ {{ $enclosure = index . "-url" -}}
+ {{ end }}
{{ end -}}
{{ end }}
@@ -89,6 +96,7 @@
"FeedDateTitle" ($date | plainify | htmlUnescape | time.Format "Monday, January 2 2006 at 15:04:05 MST")
"FeedDescription" ($description | plainify | htmlUnescape)
"FeedDescriptionShort" (delimit (first 1 (split ($description | plainify | htmlUnescape) "\n")) " " | truncate 250)
+ "FeedEnclosure" ($enclosure | plainify | htmlUnescape)
"FeedLink" ($link | plainify | htmlUnescape)
"FeedName" (delimit ((delimit (first 3 (split ($sourceTitle | plainify | htmlUnescape) " ")) " ") | findRE "^([^.|:|?|!]+)") " " | replaceRE "[^a-zA-Z ]" "")
"FeedSourceDescription" ($sourceDescription | plainify | htmlUnescape)
@@ -144,6 +152,26 @@
{{ $content = .FeedTitle }}
{{ end }}
+ {{ $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 }}
+ {{ end }}
+ {{ end }}
+
{{ $markdown := resources.ExecuteAsTemplate
$path
(dict
@@ -152,6 +180,7 @@
"date" .FeedDateTime
"description" $description
"domain" .FeedSourceDomain
+ "enclosure" $enclosure
"image" $imageSource
"link" .FeedLink
"name" .FeedName