{{- $rel := "" -}} {{- $external := false -}} {{- $noreferrer := true -}} {{- if eq .Noreferrer false -}} {{- $noreferrer = false -}} {{- end -}} {{- $url := urls.Parse .Destination -}} {{- if $url.IsAbs | or .Newtab -}} {{- $rel = cond $noreferrer "external nofollow noopener noreferrer" "external nofollow" -}} {{- $external = true -}} {{- end -}} {{- $class := .Class | default "" -}} {{- if eq .Card true -}} {{- $class = trim (printf "%v %v" "card-link" $class) " " -}} {{- end -}} {{- if ne .Card true -}} {{- with .Icon -}} {{- partial "plugin/icon.html" . }} {{ end -}} {{- with .Content -}} {{- . | safeHTML -}} {{- end -}} {{- if (.ExternalIcon | default false) | and $external | and (eq (hasPrefix .Content ``) | or (strings.HasSuffix .Content `):`)) false) -}} {{- if .Download -}} {{- dict "Class" "fa-solid fa-cloud-download-alt ms-1 text-secondary" | partial "plugin/icon.html" -}} {{- else -}} {{- dict "Class" "fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" | partial "plugin/icon.html" -}} {{- end -}} {{- else if .Download }} {{- dict "Class" "fa-solid fa-download ms-1 text-secondary" | partial "plugin/icon.html" -}} {{- end -}} {{- else -}} {{- $cardIcon := .CardIcon -}} {{- if (not $cardIcon) | and $url.Host -}} {{- with partial "function/get-remote-image.html" (dict "Src" (add "https://favicon.im/" $url.Host)) -}} {{- $cardIcon = .RelPermalink -}} {{- else with partial "function/get-remote-image.html" (dict "Src" (add "https://api.lruihao.cn/google/s2/favicons?sz=64&domain=" $url.Host)) -}} {{- $cardIcon = .RelPermalink -}} {{- end -}} {{- end -}} {{- with .Icon -}} {{- partial "plugin/icon.html" . }} {{ end -}} {{- with .Content -}} {{- . | safeHTML -}} {{- end -}} {{- $u := urls.Parse .Destination -}} {{- $u.String | safeURL | strings.TrimPrefix (add $u.Scheme "://") -}} {{- if .Download -}} {{- else -}} {{- with $cardIcon -}} {{- if (strings.HasPrefix . "fa") -}} {{- else -}} card image {{- end -}} {{- else -}} {{- end -}} {{- end -}} {{- end -}} {{- /* EOF */ -}}