relative images/URLs do not work in some feed readers. Thanks, Peter. See render-image.html

This commit is contained in:
Wouter Groeneveld 2021-07-11 11:45:33 +02:00
parent f1aea1a4af
commit 6a51a01e71
2 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,6 @@
<figure>
<a href="{{ .Destination | safeURL }}" class="lbox">
<img loading="lazy" class="img-responsive" src="{{ .Destination | safeURL }}" {{ with .Text }} alt="{{ . }}"{{ end }} {{ with .Title}} title="{{ . }}" alt="{{ . }}"{{ end }}>
<img src="{{ .Destination | safeURL }}" loading="lazy" class="img-responsive"{{ with .Text }} alt="{{ . }}"{{ end }}{{ with .Title}} title="{{ . }}" alt="{{ . }}"{{ end }}>
</a>
{{ with .Title }}
<figcaption>{{ . }}</figcaption>

View File

@ -50,23 +50,26 @@
{{ $eagerLoadImg := "src=" }}
{{ $contentImg := .Content | replaceRE $lazyLoadImg $eagerLoadImg | safeHTML }}
{{ $noscriptImg := "<noscript class=\"noscript-lazyload\">(.*)</noscript>" }}
{{ $content := $contentImg | replaceRE $noscriptImg "" | 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 `<img src="/(.*?)"` (printf "%s%s%s" "<img src=\"" $baseurl "$1\"") $content }}
{{ $content = replaceRE `a href="/(.*?)"` (printf "%s%s%s" "a href=\"" $baseurl "$1\"") $content }}
<description>
{{ `<![CDATA[ ` | safeHTML }}
{{ $content | safeHTML }}
<p>
By <a href="/about">{{ .Site.Author.name }}</a> on <time datetime="{{ .Lastmod.Format "2006-01-02" }}">{{ .Lastmod.Format (.Site.Params.dateFormat | default "2 January 2006") }}</time>.
By <a href="{{ $baseurl }}about">{{ .Site.Author.name }}</a> on <time datetime="{{ .Lastmod.Format "2006-01-02" }}">{{ .Lastmod.Format (.Site.Params.dateFormat | default "2 January 2006") }}</time>.
</p>
{{ if .Params.game_name }}
<hr/>
<p>
{{ with .Params.game_platform }}
&nbsp;Played on: <a href="/platforms/{{ lower . }}">{{ . }}</a><br/>
&nbsp;Played on: <a href="{{ $baseurl }}platforms/{{ lower . }}">{{ . }}</a><br/>
{{ end }}
{{ with .Params.game_genre }}
{{ $tag := replaceRE `\s` "-" . }}
&nbsp;Genre: <a href="/tags/{{ $tag | lower }}">{{ . }}</a><br/>
&nbsp;Genre: <a href="{{ $baseurl }}tags/{{ $tag | lower }}">{{ . }}</a><br/>
{{ end }}
{{ with .Params.game_release_year }}
&nbsp;Release year: {{ . }}<br/>