Support markdown in link text (#251)

- Add back the `safeURL` transform.
- Add `rel="noopener"` for external links.
- Followup to #247, which removed the `safeURL` transformation.
This commit is contained in:
Patrice Chalin 2020-05-28 17:50:21 -04:00 committed by GitHub
parent 3a008dc431
commit cb715ab559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -1,2 +1,10 @@
{{ $isRemote := hasPrefix .Destination "http" }}
<a href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank"{{ end }}>{{- .Text -}}{{ if $isRemote }}&nbsp;<sup><i class="fas fa-external-link-alt"></i></sup>{{ end }}</a>
{{ $isRemote := hasPrefix .Destination "http" -}}
<a href="{{ .Destination | safeURL }}"
{{- with .Title }} title="{{ . }}"{{ end -}}
{{- if $isRemote }} target="_blank" rel="noopener"{{ end -}}
>
{{- .Text | safeHTML -}}
{{ if $isRemote -}}
&nbsp;<sup><i class="fas fa-external-link-alt"></i></sup>
{{- end -}}
</a>