change relative urls and image starting with / to absolute in rss feed

This commit is contained in:
Wouter Groeneveld 2022-05-09 08:56:12 +02:00
parent 78c144a115
commit 3e0360b6f4
2 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,18 @@
[
{
"author": {
"name": "Jan Boddez",
"picture": "/pictures/boddez.net"
},
"name": "",
"content": "Liked https://brainbaking.com/post/2022/05/how-to-properly-store-your-gameboy-cartridges/.",
"published": "2022-05-08T10:10:18+02:00",
"url": "https://jan.boddez.net/likes/c3de260e59",
"type": "like",
"source": "https://jan.boddez.net/likes/c3de260e59",
"target": "https://brainbaking.com/post/2022/05/how-to-properly-store-your-gameboy-cartridges/",
"relativeTarget": "/post/2022/05/how-to-properly-store-your-gameboy-cartridges/"
},
{
"author": {
"name": "Frank Meeuwsen",

View File

@ -54,8 +54,10 @@
{{ $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 `<img src="/(.*?)"` (printf "%s%s%s" "<img src=\"" $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=\"" .Permalink "../$1\"") $content }}
{{ $content = replaceRE `a href="/(.*?)"` (printf "%s%s%s" "a href=\"" $baseurl "$1\"") $content }}
<description>
{{ `<![CDATA[ ` | safeHTML }}
{{ if .Params.bigimg }}