Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro committed Jun 15, 2024
1 parent 1234177 commit 3f6a48f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
22 changes: 15 additions & 7 deletions themes/jaeger-docs/layouts/index.html
Original file line number Diff line number Diff line change
@@ -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 "<img[^>]+src=\"([^\">]+)\"" (index $v "content:encoded") 1 }}
{{ $content := index $v "encoded" }}
{{ with strings.FindRESubmatch "<img[^>]+src=\"([^\">]+)\"" $content 1 }}
{{ if . }} {{/* If image found in post */}}
{{ $findMatch := index . 0 }} {{/* Choose the first image */}}
{{ with $findMatch }}
Expand All @@ -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) }}
Expand Down
5 changes: 2 additions & 3 deletions themes/jaeger-docs/layouts/partials/home/articles.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ <h1 class="title is-spaced">Latest articles from our blog</h1>
{{ $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 }}

<li class="blog__post">
<a href="{{ $link }}">
Expand Down

0 comments on commit 3f6a48f

Please sign in to comment.