diff options
author | tdro <tdro@noreply.example.com> | 2022-08-10 01:06:01 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-08-10 01:06:01 -0400 |
commit | a2753213c7a392e3f5d937c67580c356f29d71ba (patch) | |
tree | 9d42c2e1261e2698f0e628017dc856e58a77df7c /themes/default/layouts/partials/generate-feeds.html | |
parent | 8fff15f984b7d0b9a93c2ac4ef7b8a38230e7454 (diff) | |
download | canory-a2753213c7a392e3f5d937c67580c356f29d71ba.tar.gz canory-a2753213c7a392e3f5d937c67580c356f29d71ba.tar.bz2 canory-a2753213c7a392e3f5d937c67580c356f29d71ba.zip |
themes/default/layouts/partials/generate-feeds: Try to resolve home links
Carefully..
Diffstat (limited to 'themes/default/layouts/partials/generate-feeds.html')
-rw-r--r-- | themes/default/layouts/partials/generate-feeds.html | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/themes/default/layouts/partials/generate-feeds.html b/themes/default/layouts/partials/generate-feeds.html index 62aba9d..76186fd 100644 --- a/themes/default/layouts/partials/generate-feeds.html +++ b/themes/default/layouts/partials/generate-feeds.html @@ -19,9 +19,10 @@ {{- $description := "No description found." -}} {{- $enclosure := "" -}} {{- $imageLink := "" -}} - {{- $link := "https://example.com/link" -}} + {{- $link := "https://example.com/link/" -}} {{- $sourceDescription := "No source description found." -}} - {{- $sourceLink := "https://example.com/" -}} + {{- $sourceHome := "" -}} + {{- $sourceLink := "https://example.com/rss/" -}} {{- $sourceTitle := "No source title found" -}} {{- $title := "No Title Found" -}} @@ -32,7 +33,8 @@ {{- if reflect.IsSlice .link -}} {{- if reflect.IsMap (index .link 0) -}} - {{- $sourceLink = index (index .link 0) "-href" -}} + {{- $sourceLink = index (first 1 .link) 0 "-href" -}} + {{- $sourceHome = index (last 1 .link) 0 -}} {{- else -}} {{- $sourceLink = index .link 0 -}} {{- end -}} @@ -167,6 +169,7 @@ "FeedSourceDescription" ($sourceDescription | plainify | htmlUnescape) "FeedSourceDomain" ($sourceDomain) "FeedSourceLink" ($sourceLink | plainify | htmlUnescape) + "FeedSourceHome" ($sourceHome | plainify | htmlUnescape) "FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape) "FeedTitle" ($title | plainify | htmlUnescape) ) @@ -203,7 +206,9 @@ -}} {{- $template := resources.Get "templates/markdown-feed.yaml" -}} - {{- $name := print (delimit (first 8 (split (.FeedTitle | urlize) "-")) "-" | humanize | urlize) "-" (.FeedLink | sha256 | truncate 8 "") | humanize | urlize -}} + {{- $name := print (delimit (first 8 (split (.FeedTitle | urlize) "-")) "-" | humanize | urlize) "-" (.FeedLink | sha256 | truncate 8 "") -}} + {{- $name = partial "function-strip-urlchars.html" $name -}} + {{- $path := print "/data/generates/content/" $author.user "/feeds/" $name ".md" -}} {{- $description := .FeedDescriptionShort -}} @@ -226,6 +231,7 @@ "domain" .FeedSourceDomain "enclosure" .FeedEnclosure "image" $imageSource + "home" .FeedSourceHome "link" .FeedLink "name" .FeedName "raw" (strings.TrimLeft "/" $path) @@ -265,7 +271,7 @@ <a title="{{ .FeedSourceDescription }}" - href="{{ .FeedSourceLink }}"> + href="{{ or .FeedSourceHome .FeedSourceLink }}"> {{ .FeedSourceTitle }} </a> </web-ring-item> |