You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
695 B
17 lines
695 B
<!-- https://github.com/bep/hugo-mod-misc/blob/79a51b35c8cd162bc9977aba0c07bd0e93f69d25/render-hooks/layouts/_default/_markup/render-link.html -->
|
|
{{- $link := .Destination -}}
|
|
{{ $isRemote := strings.HasPrefix $link "http" }}
|
|
{{- if not $isRemote -}}
|
|
{{ $url := urls.Parse .Destination }}
|
|
{{- if $url.Path -}}
|
|
{{ $fragment := "" }}
|
|
{{- with $url.Fragment }}
|
|
{{ $fragment = printf "#%s" . }}
|
|
{{ end -}}
|
|
{{- with .Page.GetPage $url.Path }}
|
|
{{ $link = printf "%s%s" .RelPermalink $fragment }}
|
|
{{ end }}
|
|
{{ end -}}
|
|
{{- end -}}
|
|
<a href="{{ $link | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank"{{ end }}>{{ .Text | safeHTML }}</a>{{ "" -}}
|