diff --git a/themes/jaeger-docs/layouts/index.html b/themes/jaeger-docs/layouts/index.html index d3114971..bec72d70 100644 --- a/themes/jaeger-docs/layouts/index.html +++ b/themes/jaeger-docs/layouts/index.html @@ -1,16 +1,23 @@ {{ define "main" }} -{{ $xml := "" }} -{{ with resources.Get "https://medium.com/feed/jaegertracing" }} - {{ $xml = .Content | html }} +{{ $rss := "" }} +{{ with resources.GetRemote "https://medium.com/feed/jaegertracing" }} + {{ with .Err }} + {{ errorf "%s" . }} + {{ else }} + {{ $rss = . | transform.Unmarshal }} + {{ end }} {{ end }} -{{ $posts := first 100 $xml.channel.item }} -{{ $imgLinks := slice }} + +{{/* Parse image links */}} {{ $defaultImgLink := "/img/jaeger-icon-color.png" }} +{{ warnf "Downloaded RSS feed for: %v" $rss.channel.title }} +{{ $posts := first 20 $rss.channel.item }} +{{ $imgLinks := slice }} -{{/* Parse Medium's post first image link */}} {{ range $k, $v := $posts }} {{ $imgLink := $defaultImgLink }} - {{ with strings.FindRESubmatch "]+src=\"([^\">]+)\"" (index $v "content:encoded") 1 }} + {{ $content := index $v "encoded" }} + {{ with strings.FindRESubmatch "]+src=\"([^\">]+)\"" $content 1 }} {{ if . }} {{/* If image found in post */}} {{ $findMatch := index . 0 }} {{/* Choose the first image */}} {{ with $findMatch }} @@ -22,6 +29,7 @@ {{ end }} {{ end }} {{ $imgLinks = $imgLinks | append $imgLink }} + {{ warnf "Post: %v" $v.title }} {{ end }} {{ partial "home/hero.html" (dict "posts" $posts "title" site.Title "tagline" site.Params.tagline "latestVersion" site.Params.latest) }} diff --git a/themes/jaeger-docs/layouts/partials/home/articles.html b/themes/jaeger-docs/layouts/partials/home/articles.html index 35d9a45d..e3a786dc 100644 --- a/themes/jaeger-docs/layouts/partials/home/articles.html +++ b/themes/jaeger-docs/layouts/partials/home/articles.html @@ -8,11 +8,10 @@

Latest articles from our blog

{{ $link := .link }} {{ $img := (index $.imgLinks $idx) }} {{ $title := .title | plainify }} - {{ $author := .author }} + {{ $author := .creator }} {{ $dateRaw := .pubDate }} {{ $date := dateFormat "January 2, 2006" $dateRaw }} - {{ $summary := .content | plainify | truncate 150 }} - + {{ $summary := .encoded | plainify | truncate 150 }}