diff options
Diffstat (limited to 'themes/default/layouts/partials/feeds-generate.html')
-rw-r--r-- | themes/default/layouts/partials/feeds-generate.html | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/themes/default/layouts/partials/feeds-generate.html b/themes/default/layouts/partials/feeds-generate.html new file mode 100644 index 0000000..cec17d8 --- /dev/null +++ b/themes/default/layouts/partials/feeds-generate.html @@ -0,0 +1,154 @@ +{{- $author := index .Site.Data.authors ((or .Params.author .Site.Author.default.user) | default "default") -}} + +{{ $feeds := slice }} + +{{- if $author.webring.rss -}} + {{ range $key, $value := (seq 3) }} + {{ range $author.webring.rss -}} + + {{ with resources.GetRemote . }} + {{- with .Err -}} + {{- warnf "%s" . -}} + {{- end -}} + {{ end }} + + {{ with resources.GetRemote . | transform.Unmarshal -}} + + {{- $title := "No Title Found" -}} + {{- $link := "https://example.com/link" -}} + {{- $description := "No description found." -}} + {{- $content := "No content found." -}} + {{- $sourceTitle := "No source title found" -}} + {{- $sourceLink := "https://example.com/" -}} + {{- $sourceDescription := "No source description found." -}} + {{- $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" -}} + {{ else -}} + {{ $sourceLink = index .link 0 -}} + {{ end -}} + + {{ $sourceDescription = .description -}} + + {{ $sourceTitle = .title -}} + + {{ range first $value .item -}} + {{ $description = .description -}} + {{ $content = .description -}} + {{ $title = .title -}} + {{ $link = .link -}} + {{ $date = .pubDate -}} + {{ $dateTime = .pubDate -}} + {{ $dateTitle = .pubDate -}} + {{ end -}} + + {{ else -}} + + {{ $sourceLink = index (index .link 0) "-href" -}} + {{ $sourceTitle = .title -}} + {{ $sourceDescription = .subtitle -}} + + {{ range first $value .entry -}} + + {{ if reflect.IsMap .title -}} + {{ $title = index .title "#text" -}} + {{ else -}} + {{ $title = .title -}} + {{ end -}} + + {{ $date = .updated -}} + {{ $dateTime = .updated -}} + {{ $dateTitle = .updated -}} + + {{ $link = .id -}} + + {{ with .content -}} + {{ $description = index . "#text" -}} + {{ $content = index . "#text" -}} + {{ end -}} + {{ with .summary -}} + {{ $description = index . "#text" -}} + {{ $content = index . "#text" -}} + {{ end -}} + {{ end -}} + + {{ end -}} + + {{ + $feeds = $feeds | append (dict + "FeedTitle" ($title | plainify | htmlUnescape) + "FeedLink" ($link | plainify | htmlUnescape) + "FeedDescription" (delimit ($description | plainify | htmlUnescape | findRE "^([^.|:|?|!]+)") " ") + "FeedContent" ($content | plainify | htmlUnescape) + "FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape) + "FeedSourceLink" ($sourceLink | plainify | htmlUnescape) + "FeedSourceDescription" ($sourceDescription | plainify | htmlUnescape) + "FeedDate" ($date | plainify | htmlUnescape | time.Format "January 2, 2006") + "FeedDateTime" ($dateTime | plainify | htmlUnescape | time.Format "2006-01-02T15:04:05Z") + "FeedDateTitle" ($dateTitle | plainify | htmlUnescape | time.Format "Monday, January 2 2006 at 15:04:05 MST") + ) + }} + + {{ end }} + {{ end }} + {{ end }} + + {{ range $feeds }} + {{ $template := resources.Get "templates/markdown.yaml" }} + {{ $markdown := resources.ExecuteAsTemplate + (print "/data/generators/content/" $author.user "/feeds/" (urlize (replace .FeedTitle "/" "-")) ".md") + (dict + "content" (print (or .FeedDescription .FeedTitle) ".") + "tags" "[rss]" + "rss" true + "date" .FeedDateTime + ) + $template + }} + {{ $writeToFile := $markdown.RelPermalink }} + {{ end }} + + <web-ring> + <h1>Web Ring</h1> + <aside> + {{ range first 3 (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 (print .FeedDescription ".") -}} + {{ "--" | markdownify }} + {{ . }} + {{- end }} + </p> + + <a + rel="noopener" + target="_blank" + title="{{ .FeedSourceDescription }}" + href="{{ .FeedSourceLink }}"> + {{ .FeedSourceTitle }} + </a> + </web-ring-item> + {{ end }} + </aside> + </web-ring> +{{ end }} |