Skip to content

Commit

Permalink
fix: dont apply relURL function to remote urls in render-link template
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys committed Feb 21, 2021
1 parent ece9d46 commit 673dc72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions exampleSite/content/contact.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ title: "Get in touch"
---

- **E-Mail:** <!-- spellchecker-disable -->mail [ett] example.com<!-- spellchecker-enable -->
- **Mailto:** [[email protected]](mailto:[email protected])
- **Matrix:** @john:example.com
- **XMPP:** [email protected]
9 changes: 7 additions & 2 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
{{ $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>
{{- $raw := or (hasPrefix .Text "<img") (hasPrefix .Text "<figure") -}}
{{- $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>

0 comments on commit 673dc72

Please sign in to comment.