2024-06-23 12:46:07 -07:00
|
|
|
{{- $scratch := newScratch -}}
|
2024-06-19 17:30:46 -07:00
|
|
|
{{- $absoluteDest := absLangURL .Destination -}}
|
|
|
|
{{- $siteRootUrl := absLangURL "" -}}
|
|
|
|
{{- $isExternal := not (hasPrefix $absoluteDest $siteRootUrl) -}}
|
2024-06-23 12:46:07 -07:00
|
|
|
{{- $isSamePage := hasPrefix .Destination "#" -}}
|
|
|
|
|
|
|
|
{{- if $isSamePage -}}
|
|
|
|
{{- $scratch.Set "class" "same-page-link" -}}
|
|
|
|
{{- if index (.Page.Scratch.Get "definedSections") .Destination -}}
|
|
|
|
{{- $scratch.Set "icon" "arrow-up" -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $scratch.Set "icon" "arrow-down" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- else if $isExternal -}}
|
|
|
|
{{- $scratch.Set "class" "external-link" -}}
|
|
|
|
{{- $scratch.Set "icon" "external-link" -}}
|
|
|
|
{{- end -}}
|
2024-06-19 17:30:46 -07:00
|
|
|
<a href="{{ .Destination | safeURL }}"
|
|
|
|
{{- with .Title }} title="{{ . }}"{{ end -}}
|
2024-06-23 12:46:07 -07:00
|
|
|
{{- with $scratch.Get "class" -}}
|
|
|
|
class="{{ . }}"
|
|
|
|
{{- end -}}
|
2024-06-19 17:30:46 -07:00
|
|
|
{{- if $isExternal -}}
|
2024-06-23 12:46:07 -07:00
|
|
|
target="_blank" rel="noopener noreferrer"
|
2024-06-19 17:30:46 -07:00
|
|
|
{{- end -}}
|
|
|
|
>
|
|
|
|
{{- with .Text | safeHTML }}{{ . }}{{ end -}}
|
2024-06-23 12:46:07 -07:00
|
|
|
{{- with $scratch.Get "icon" -}}{{- partial "icon.html" . -}}{{- end -}}
|
2024-06-19 17:30:46 -07:00
|
|
|
</a>
|
|
|
|
{{- /* chomp trailing newline */ -}}
|