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-10 20:15:14 +02:00
parent 1def5cdd7e
commit 1c78006b68
2 changed files with 7 additions and 3 deletions

View File

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

View File

@ -47,7 +47,11 @@
{{ end }}
{{ end }}
{{ $content := .Content | safeHTML }}
{{ $content := .Content }}
<!-- relative images/URLs do not work in some feed readers. Thanks, Peter. See render-image.html -->
{{ $content = replaceRE `<img src="../(.*?)"` (printf "%s%s%s" "<img src=\"" .Permalink "../$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=\"" .Permalink "../$1\"") $content }}
<description>
{{ `<![CDATA[ ` | safeHTML }}
{{ if .Params.bigimg }}
@ -56,7 +60,7 @@
</p>
{{ end }}
{{ $content }}
{{ $content | safeHTML }}
<p>
By <a href="/about">{{ .Site.Author.name }}</a> on {{ .Date.Format "2 January 2006" }}.