render-link.html (2142B)
1 <a href="{{ .Destination | safeURL }}" 2 {{ $brand := "font-awesome-flag" }} 3 {{ $title := .Title }} 4 5 {{ $root := .Page.Site.BaseURL | replaceRE "^https?://(en.|www.|m.)?([^/]+).*" "$2" }} 6 {{ $domain := .Destination | replaceRE "^https?://(en.|www.|m.)?([^/]+).*" "$2" }} 7 {{ if eq $domain "github.com" }} 8 {{ $brand = "github" }} 9 {{ else if eq $domain "twitter.com" }} 10 {{ $brand = "twitter" }} 11 {{ else if eq $domain "patreon.com" }} 12 {{ $brand = "patreon" }} 13 {{ else if eq $domain "instagram.com" }} 14 {{ $brand = "instagram" }} 15 {{ else if eq $domain "kickstarter.com" }} 16 {{ $brand = "kickstarter" }} 17 {{ else if eq $domain "keybase.io" }} 18 {{ $brand = "keybase" }} 19 {{ else if eq $domain "openstreetmap.org" }} 20 {{ $brand = "periscope" }} 21 {{ else if eq $domain "apps.apple.com" }} 22 {{ $brand = "app-store" }} 23 {{ else if eq $domain "apple.stackexchange.com" }} 24 {{ $brand = "stack-exchange" }} 25 {{ else if eq $domain "news.ycombinator.com" }} 26 {{ $brand = "hacker-news" }} 27 {{ else if eq $domain "git.ybbond.id" }} 28 {{ $brand = "git-alt" }} 29 {{ else if or (eq $domain "wikipedia.com") (or (eq $domain "wikipedia.com") (eq $domain "id.wikipedia.org")) }} 30 {{ $brand = "wikipedia-w" }} 31 {{ end}} 32 33 {{ $first := truncate 1 "" $domain }} 34 {{ $slash := (eq $first "/" )}} 35 {{ $hash := (eq $first "#") }} 36 {{ $not_internal := (eq true (and (and (ne $first "/") (ne $first "#")) (ne $domain $root))) }} 37 38 {{ if ne .Title "" }} 39 title="{{ .Title }}" 40 {{ else if $slash }} 41 title="Internal link with text: {{ .Text | safeHTML }}" 42 {{ else if $hash }} 43 title="Same post link with text: {{ .Text | safeHTML }}" 44 {{ else }} 45 title="Link to {{ $domain }} with text: {{ .Text | safeHTML }}" 46 {{ end }} 47 data-goatcounter-click="{{ .Text }}" 48 {{ if strings.HasPrefix .Destination "http" }} 49 target="_blank" 50 rel="noreferrer noopener" 51 {{ else }} 52 data-rel="prefetch" 53 {{ end }} 54 >{{ .Text | safeHTML }}{{if and (ne false $not_internal) (ne $domain "ybbond.goatcounter.com") }} <i class="fab fa-{{ $brand }}"></i>{{ end }}</a>