fix: dont apply relURL function to remote urls in render-link template

This commit is contained in:
Robert Kaussow 2021-02-21 21:16:11 +01:00
parent ece9d46a3e
commit 673dc72be0
No known key found for this signature in database
GPG Key ID: 65362AE74AF98B61
2 changed files with 8 additions and 2 deletions

View File

@ -3,5 +3,6 @@ title: "Get in touch"
--- ---
- **E-Mail:** <!-- spellchecker-disable -->mail [ett] example.com<!-- spellchecker-enable --> - **E-Mail:** <!-- spellchecker-disable -->mail [ett] example.com<!-- spellchecker-enable -->
- **Mailto:** [contact@example.com](mailto:contact@example.com)
- **Matrix:** @john:example.com - **Matrix:** @john:example.com
- **XMPP:** john@example.com - **XMPP:** john@example.com

View File

@ -1,2 +1,7 @@
{{ $raw := or (hasPrefix .Text "<img") (hasPrefix .Text "<figure") }} {{- $raw := or (hasPrefix .Text "<img") (hasPrefix .Text "<figure") -}}
<a class="gblog-post__link{{ if $raw }}--raw{{ end }}" href="{{ .Destination | safeURL | relURL }}"{{ with .Title }} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a> {{- $isRemote:= or (in .Destination ":") ( hasPrefix .Destination "//") -}}
{{- $destination := .Destination | safeURL -}}
{{- if not $isRemote -}}
{{- $destination = $destination | relURL -}}
{{- end -}}
<a class="gblog-post__link{{ if $raw }}--raw{{ end }}" href="{{ $destination }}"{{ with .Title }} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>