{{ define "main" }} {{ $rss := resources.Get "data/medium.xml" | transform.Unmarshal }} {{ $channel := dict }} {{ if not $rss }} {{ warnf "Medium feed is nil or failed to load." }} {{ $channel = dict "title" "No data" "item" (slice) }} {{ else if not ($rss.channel) }} {{ warnf "Medium feed found but missing 'channel'" }} {{ $channel = dict "title" "No data" "item" (slice) }} {{ else }} {{ $channel = $rss.channel }} {{ warnf "Loaded Medium feed for: %v" $channel.title }} {{ end }} {{ $defaultImgLink := "/img/jaeger-icon-color.png" }} {{ warnf "Loaded RSS feed for: %v" $rss.channel.title }} {{ $posts := first 20 $rss.channel.item }} {{ $imgLinks := slice }} {{ range $k, $v := $posts }} {{ $imgLink := $defaultImgLink }} {{ $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 }} {{ $findGroup := index . 1 }} {{ if . }} {{/* If src link found */}} {{ $imgLink = $findGroup }} {{ end }} {{ end }} {{ end }} {{ end }} {{ $imgLinks = $imgLinks | append $imgLink }} {{ warnf "Post: %v" $v.title }} {{ end }} {{ partial "home/hero.html" (dict "posts" $posts "title" .Title "tagline" site.Params.tagline "latestVersion" site.Params.latestV2) }} {{ partial "home/why.html" . }} {{ partial "home/features.html" . }} {{ partial "home/articles.html" (dict "posts" $posts "imgLinks" $imgLinks) }} {{ partial "home/contributing.html" . }} {{ partial "home/cncf.html" . }} {{ partial "home/thanks.html" . }} {{ end }}