Skip to content

Commit

Permalink
Fix Medium's post thumbnail (#678)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Resolves #677

## Description of the changes
- Fix Medium's post thumbnail
- Solution following:
https://medium.com/@kartikyathakur/getting-those-thumbnails-from-medium-rss-feed-183f74aefa8c

## How was this change tested?
- Manual test

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [ ] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

Signed-off-by: tico88612 <17496418+tico88612@users.noreply.github.com>
  • Loading branch information
tico88612 committed Mar 6, 2024
1 parent 82d6bdf commit f701acb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
23 changes: 21 additions & 2 deletions themes/jaeger-docs/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@
{{ with resources.GetRemote "https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/jaegertracing" }}
{{ $json = . | transform.Unmarshal }}
{{ end }}
{{ $posts := first 100 $json.items }}
{{ $posts := first 100 $json.items }}
{{ $imgLinks := slice }}
{{ $defaultImgLink := "/img/jaeger-icon-color.png" }}

{{/* Parse Medium's post first image link */}}
{{ range $k, $v := $posts }}
{{ $imgLink := $defaultImgLink }}
{{ with strings.FindRESubmatch "<img[^>]+src=\"([^\">]+)\"" (index $v "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 }}
{{ end }}

{{ partial "home/hero.html" (dict "posts" $posts "title" site.Title "tagline" site.Params.tagline "latestVersion" site.Params.latest) }}
{{ partial "home/why.html" . }}
{{ partial "home/features.html" . }}
{{ partial "home/articles.html" (dict "posts" $posts) }}
{{ partial "home/articles.html" (dict "posts" $posts "imgLinks" $imgLinks) }}
{{ partial "home/contributing.html" . }}
{{ partial "home/cncf.html" . }}
{{ end }}
4 changes: 2 additions & 2 deletions themes/jaeger-docs/layouts/partials/home/articles.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ <h1 class="title is-spaced">Latest articles from our blog</h1>

<div class="blog__container">
<ul class="blog__slider">
{{ range .posts }}
{{ range $idx, $val := .posts }}
{{ $link := .link }}
{{ $img := .thumbnail }}
{{ $img := (index $.imgLinks $idx) }}
{{ $title := .title | plainify }}
{{ $author := .author }}
{{ $dateRaw := .pubDate }}
Expand Down

0 comments on commit f701acb

Please sign in to comment.