diff options
author | tdro <tdro@noreply.example.com> | 2022-05-25 19:18:40 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-05-25 19:18:40 -0400 |
commit | 76fcd575e61a0f0e4ce602387d9a3b6098a23884 (patch) | |
tree | ebe4b9bae4d08c9f1cc402cd615229eba63c9eb2 /themes/default/layouts/partials/web-ring.html | |
parent | 8710bcdc76615374cf40af2fb8ea2304f9cdaee1 (diff) | |
download | canory-76fcd575e61a0f0e4ce602387d9a3b6098a23884.tar.gz canory-76fcd575e61a0f0e4ce602387d9a3b6098a23884.tar.bz2 canory-76fcd575e61a0f0e4ce602387d9a3b6098a23884.zip |
themes/default/layouts: Multiplex RSS feeds
Use one feed fetching logic and generate feeds as markdown. Due to generation
step hugo has to run twice to fully generate all static content.
Diffstat (limited to 'themes/default/layouts/partials/web-ring.html')
-rw-r--r-- | themes/default/layouts/partials/web-ring.html | 139 |
1 files changed, 1 insertions, 138 deletions
diff --git a/themes/default/layouts/partials/web-ring.html b/themes/default/layouts/partials/web-ring.html index cca6027..1f89616 100644 --- a/themes/default/layouts/partials/web-ring.html +++ b/themes/default/layouts/partials/web-ring.html @@ -1,138 +1 @@ -{{- $author := index .Site.Data.authors ((or .Params.author .Site.Author.default.user) | default "default") -}} - -{{- if $author.webring.rss -}} - - {{ $feeds := slice }} - - {{ range first 5 $author.webring.rss -}} - - {{ with resources.GetRemote . }} - {{- with .Err -}} - {{- warnf "%s" . -}} - {{- end -}} - {{ end }} - - {{ with resources.GetRemote . | transform.Unmarshal -}} - - {{- $title := "Example Domain" -}} - {{- $link := "https://example.com/link" -}} - {{- $description := "This domain is for use in illustrative examples in documents." -}} - {{- $content := "This content is for use in illustrative examples in documents." -}} - {{- $sourceTitle := "From Example Domain" -}} - {{- $sourceLink := "https://example.com/" -}} - {{- $sourceDescription := "The example domain." -}} - {{- $date := now.Format "January 2, 2006" -}} - {{- $dateTime := now.Format "2006-01-02T15:04:05Z" -}} - {{- $dateTitle := now.Format "Monday, January 2 2006 at 15:04:05 MST" -}} - - {{ with .channel -}} - - {{ if reflect.IsMap (index .link 0) -}} - {{ $sourceLink = index (index .link 0) "-href" | plainify | htmlUnescape -}} - {{ else -}} - {{ $sourceLink = index .link 0 | plainify | htmlUnescape -}} - {{ end -}} - - {{ $sourceDescription = .description | plainify | htmlUnescape -}} - - {{ $sourceTitle = .title | plainify | htmlUnescape -}} - - {{ range first 1 .item -}} - {{ $description = .description | plainify | htmlUnescape | truncate 50 "..." -}} - {{ $content = .description | plainify | htmlUnescape -}} - {{ $title = .title | plainify | htmlUnescape -}} - {{ $link = .link | plainify | htmlUnescape -}} - {{ $date = .pubDate | plainify | htmlUnescape | time.Format "January 2, 2006" -}} - {{ $dateTime = .pubDate | plainify | htmlUnescape | time.Format "2006-01-02T15:04:05Z" -}} - {{ $dateTitle = .pubDate | plainify | htmlUnescape | time.Format "Monday, January 2 2006 at 15:04:05 MST" -}} - {{ end -}} - - {{ else -}} - - {{ $sourceLink = index (index .link 0) "-href" | plainify | htmlUnescape -}} - {{ $sourceTitle = .title | plainify | htmlUnescape -}} - {{ $sourceDescription = .subtitle | plainify | htmlUnescape -}} - - {{ range first 1 .entry -}} - - {{ if reflect.IsMap .title -}} - {{ $title = index .title "#text" | plainify | htmlUnescape -}} - {{ else -}} - {{ $title = .title | plainify | htmlUnescape -}} - {{ end -}} - - {{ $date = .updated | plainify | htmlUnescape | time.Format "January 2, 2006" -}} - {{ $dateTime = .updated | plainify | htmlUnescape | time.Format "2006-01-02T15:04:05Z" -}} - {{ $dateTitle = .updated | plainify | htmlUnescape | time.Format "Monday, January 2 2006 at 15:04:05 MST" -}} - - {{ $link = .id -}} - {{ with .content -}} - {{ $description = (index . "#text") | plainify | htmlUnescape | truncate 50 "..." -}} - {{ $content = (index . "#text") | plainify | htmlUnescape -}} - {{ end -}} - {{ with .summary -}} - {{ $description = (index . "#text") | plainify | htmlUnescape | truncate 50 "..." -}} - {{ $content = (index . "#text") | plainify | htmlUnescape -}} - {{ end -}} - {{ end -}} - - {{ end -}} - - {{ - $feeds = $feeds | append (dict - "FeedTitle" $title - "FeedLink" $link - "FeedDescription" $description - "FeedContent" $content - "FeedSourceTitle" $sourceTitle - "FeedSourceLink" $sourceLink - "FeedSourceDescription" $sourceDescription - "FeedDate" $date - "FeedDateTime" $dateTime - "FeedDateTitle" $dateTitle - ) - }} - - {{ end }} - {{ end }} - - <web-ring> - <h1>Web Ring</h1> - <aside> - {{ range sort $feeds "FeedDateTime" "desc" }} - <web-ring-item> - <header> - <a - rel="noopener" - target="_blank" - title="{{ .FeedLink }}" - href="{{ .FeedLink }}"> - {{ .FeedTitle }} - </a> - </header> - - <p> - <time - title="{{ .FeedDateTitle }}" - datetime="{{ .FeedDateTime }}"> - {{ .FeedDate }} - </time> - {{- with .FeedDescription -}} - {{ "--" | markdownify }} - {{ . }} - {{- end }} - </p> - - <a - rel="noopener" - target="_blank" - title="{{ .FeedSourceDescription }}" - href="{{ .FeedSourceLink }}"> - {{ .FeedSourceTitle }} - </a> - </web-ring-item> - {{ end }} - </aside> - </web-ring> - -{{ end -}} +{{ partial "feeds-generate" . }} |