mirror of
https://github.com/imfing/hextra.git
synced 2025-08-25 03:57:29 -04:00

* chore: add icons * feat: add option to flag outbound links * chore: generate * docs: add configuration * chore: use with the example site * chore: use one icon with rotation
26 lines
1.0 KiB
HTML
26 lines
1.0 KiB
HTML
{{- $dest := .Destination -}}
|
|
{{- $url := urls.Parse $dest -}}
|
|
|
|
{{- if and $dest (hasPrefix $dest "/") -}}
|
|
{{- with or (.PageInner.GetPage $url.Path) (.PageInner.Resources.Get $url.Path) (resources.Get $url.Path) -}}
|
|
{{- $query := cond $url.RawQuery (printf "?%s" $url.RawQuery) "" -}}
|
|
{{- $fragment := cond $url.Fragment (printf "#%s" $url.Fragment) "" -}}
|
|
{{- $dest = printf "%s%s%s" .RelPermalink $query $fragment -}}
|
|
{{- else -}}
|
|
{{- $dest = (relURL (strings.TrimPrefix "/" $dest)) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- with . -}}
|
|
{{- $isExternal := strings.HasPrefix .Destination "http" -}}
|
|
<a href="{{ $dest | safeURL }}"
|
|
{{- with .Title -}}title="{{ . }}"{{- end -}}
|
|
{{- if $isExternal -}}target="_blank" rel="noopener"{{- end -}}
|
|
>
|
|
{{- .Text | safeHTML -}}
|
|
{{- if and .Page.Site.Params.externalLinkDecoration $isExternal -}}
|
|
{{- partial "utils/icon.html" (dict "name" "arrow-up-right" "attributes" `class="hx:inline hx:rtl:rotate-270 hx:align-baseline" height="1em"`) -}}
|
|
{{- end -}}
|
|
</a>
|
|
{{- end -}}
|