jefklakscodex/themes/jefklak-creative-portfolio/layouts/_default/rss.xml

154 lines
7.0 KiB
XML

{{- $allowedRssSections := (slice "articles" "games") -}}
{{- $baseurl := .Site.BaseURL -}}
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- printf "<?xml-stylesheet href=\"/pretty-feed-v3.xsl\" type=\"text/xsl\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc='http://purl.org/dc/elements/1.1/'>
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<copyright>© {{ $.Site.Author.name }} (CC BY 4.0).</copyright>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}
{{ if not .Date.IsZero }}<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range $pages }}
{{ if and (in $allowedRssSections .Section) (gt (len .Content) 1) (ne .Params.ignore true) }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<comments>{{ .Site.Author.mastodonlink }}</comments>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<dc:creator>{{ with $.Site.Author.name }}{{.}}{{end}}</dc:creator>
<guid>{{ .Permalink }}</guid>
{{ if .Keywords }}
{{ range .Keywords }}
<category>{{ . }}</category>
{{ end }}
{{ else if .Params.tags }}
{{ range .Params.tags }}
<category>{{ . }}</category>
{{ end }}
{{ end }}
{{- $lazyLoadImg := "data-src=" -}}
{{- $eagerLoadImg := "src=" -}}
{{- $contentImg := .Content | replaceRE $lazyLoadImg $eagerLoadImg | safeHTML -}}
{{- $content := .Content -}}
<!-- relative images/URLs do not work in some feed readers. Thanks, Peter. See render-image.html -->
{{- $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 -}}
<description>
{{ `<![CDATA[ ` | safeHTML }}
{{ $content | safeHTML }}
{{ if isset .Params "score" }}
<p>
{{- $score := .Params.score -}}
<strong>Verdict</strong>: {{ $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}}.
</p>
{{ 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 }}
<p>
<strong><em>{{ .Params.series }}</em> series</strong>&nbsp;&nbsp;&#9657;
{{- range $series -}}
&nbsp;&nbsp;<a href="{{ .Permalink }}">{{ .Params.game_name }}</a>&nbsp;&nbsp;&#9675;
{{- end -}}
</p>
{{ 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" }}
<p>
<strong>Related games</strong>&nbsp;&nbsp;&#9657;
{{- range $related | uniq -}}
&nbsp;&nbsp;<a href="{{ .Permalink }}">{{ .Params.game_name }}</a>&nbsp;&nbsp;&#9675;
{{- end -}}
</p>
{{ end }}
<p>
By <a href="/about">{{ .Site.Author.name }}</a> on <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format (.Site.Params.dateFormat | default "2 January 2006") }}</time>.
</p>
{{ if .Params.game_name }}
<hr/>
<p>
{{- $platform := .CurrentSection.Title -}}
{{ with .CurrentSection.Params.platform }}
&nbsp;Played on: <a href="/games/{{ lower . }}">{{ $platform }}</a><br/>
{{- end -}}
{{ with .Params.game_genre }}
{{ $tag := replaceRE `\s` "-" . }}
&nbsp;Genre: <a href="/tags/{{ $tag | lower }}">{{ . }}</a><br/>
{{- end -}}
{{ with .Params.game_release_year }}
&nbsp;Release year: {{ . }}<br/>
{{- end -}}
{{ with .Params.game_developer }}
&nbsp;Developer: {{ . }}<br/>
{{- end -}}
{{ with .Params.howlongtobeat_hrs }}
&nbsp;How long to beat: <code>{{ . }}</code> hr{{ if gt . 1}}s{{ end }}<br/>
{{- end -}}
{{- $thumb := "" -}}
{{- if .Params.image -}}
{{- $thumb = .Params.image -}}
{{- else -}}
{{- if .Params.howlongtobeat_id -}}
{{- $thumb = (printf "%scover.jpg" .Page.Permalink) -}}
{{- end -}}
{{- end -}}
{{ if ne $thumb "" }}
<img src="{{ $thumb | absURL }}" alt="game cover image" alt="game cover" style="border: 1px solid black"/>
{{ end }}
</p>
{{ end }}
]]>
</description>
</item>
{{ end }}
{{ end }}
</channel>
</rss>