From 02301428b73d3907b8d19c361643729ae4f76eee Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Wed, 3 Jan 2024 17:47:45 +0100 Subject: [PATCH] related series: add to the rss feed --- .../layouts/_default/rss.xml | 86 ++++++++++++++----- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/themes/jefklak-creative-portfolio/layouts/_default/rss.xml b/themes/jefklak-creative-portfolio/layouts/_default/rss.xml index b364d84..e169aec 100644 --- a/themes/jefklak-creative-portfolio/layouts/_default/rss.xml +++ b/themes/jefklak-creative-portfolio/layouts/_default/rss.xml @@ -45,57 +45,101 @@ {{ . }} {{ end }} {{ end }} - {{ $lazyLoadImg := "data-src=" }} - {{ $eagerLoadImg := "src=" }} - {{ $contentImg := .Content | replaceRE $lazyLoadImg $eagerLoadImg | safeHTML }} + {{- $lazyLoadImg := "data-src=" -}} + {{- $eagerLoadImg := "src=" -}} + {{- $contentImg := .Content | replaceRE $lazyLoadImg $eagerLoadImg | safeHTML -}} - {{ $content := .Content }} + {{- $content := .Content -}} - {{ $content = replaceRE `a href="(#.*?)"` (printf "%s%s%s" "a href=\"" .Permalink "$1\"") $content }} - {{ $content = replaceRE `a href="/(.*?)"` (printf "%s%s%s" "a href=\"" $baseurl "$1\"") $content }} + {{- $content = replaceRE `a href="(#.*?)"` (printf "%s%s%s" "a href=\"" .Permalink "$1\"") $content -}} + {{- $content = replaceRE `a href="/(.*?)"` (printf "%s%s%s" "a href=\"" $baseurl "$1\"") $content -}} {{ ` - {{ $score := .Params.score }} + {{- $score := .Params.score -}} Verdict: {{ $score }}/5—{{ if eq $score 5 }}Amazing{{ else if eq $score 4 }}Great{{ else if eq $score 3 }}Good{{ else if eq $score 2 }}Mediocre{{ else if eq $score 1 }}Bad{{ else }}Indifferent{{ end}}.

{{ end }} + {{- $series := slice -}} + {{- if isset .Params "series" -}} + {{- $series = (where .Site.Pages ".Params.series" "eq" .Params.series).ByParam "game_release_year" -}} + {{- $has_series := $series | len -}} + {{ if gt $has_series 1 }} +

+ {{ .Params.series }} series  ▹ + {{- range $series -}} +   {{ .Params.game_name }}  ○ + {{- end -}} +

+ {{ end }} + {{ end }} + + {{- $currRellink := substr .RelPermalink 0 -1 -}} + {{- $currContent := .Content -}} + {{- $currTitle := .Title -}} + {{- $backlinks := slice -}} + {{- $forwardlinks := slice -}} + {{- range (where (where .Site.Pages ".Section" "in" (slice "articles" "games")) ".Params.ignore" "!=" "true") -}} + {{- $found := findRE $currRellink .Content 1 -}} + {{- if and $found (ne .Title $currTitle) -}} + {{- $backlinks = $backlinks | append . -}} + {{- else -}} + {{- $rellink := substr .RelPermalink 0 -1 -}} + {{- $found = findRE $rellink $currContent 1 -}} + {{- if and $found (ne .Title $currTitle) -}} + {{- $forwardlinks = $forwardlinks | append . -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- $rel := append $backlinks $forwardlinks -}} + {{ $related := (where ($rel | complement $series) ".Params.game_name" "ne" nil) }} + {{ $has_related := $related | len }} + {{ if gt $has_related 0 }} + {{- $related = sort $related ".Params.game_release_year" "asc" }} +

+ Related games  ▹ + {{- range $related | uniq -}} +   {{ .Params.game_name }}  ○ + {{- end -}} +

+ {{ end }} +

By {{ .Site.Author.name }} on .

{{ if .Params.game_name }}

- {{ $platform := .CurrentSection.Title }} + {{- $platform := .CurrentSection.Title -}} {{ with .CurrentSection.Params.platform }}  Played on: {{ $platform }}
- {{ end }} + {{- end -}} {{ with .Params.game_genre }} {{ $tag := replaceRE `\s` "-" . }}  Genre: {{ . }}
- {{ end }} + {{- end -}} {{ with .Params.game_release_year }}  Release year: {{ . }}
- {{ end }} + {{- end -}} {{ with .Params.game_developer }}  Developer: {{ . }}
- {{ end }} + {{- end -}} {{ with .Params.howlongtobeat_hrs }}  How long to beat: {{ . }} hr{{ if gt . 1}}s{{ end }}
- {{ end }} + {{- end -}} - {{ $thumb := "" }} - {{ if .Params.image }} - {{ $thumb = .Params.image }} - {{ else }} - {{ if .Params.howlongtobeat_id }} - {{ $thumb = (printf "%scover.jpg" .Page.Permalink) }} - {{ end }} - {{ end }} + {{- $thumb := "" -}} + {{- if .Params.image -}} + {{- $thumb = .Params.image -}} + {{- else -}} + {{- if .Params.howlongtobeat_id -}} + {{- $thumb = (printf "%scover.jpg" .Page.Permalink) -}} + {{- end -}} + {{- end -}} {{ if ne $thumb "" }} game cover image {{ end }}