|
@@ -0,0 +1,49 @@
|
|
1
|
+<!-- {{/*
|
|
2
|
+HTML attributes: href [default: "#"], class, referrerpolicy, target [default: "_blank"], rel [default: "external noopener"]
|
|
3
|
+Custom attributes: text [default: Inner], body [default: href], itemtype
|
|
4
|
+
|
|
5
|
+Basic usage:
|
|
6
|
+{{< external "https://after-dark.habd.as" />}}
|
|
7
|
+{{< external text="After Dark" href="//after-dark.habd.as" />}}
|
|
8
|
+{{< external class="muted" href="//after-dark.habd.as" />}}
|
|
9
|
+{{< external "gopher://gopher.quux.org:70" />}}
|
|
10
|
+
|
|
11
|
+With external link styling removed:
|
|
12
|
+{{< external rel="noopener" href="https://keybase.io/jhabdas" />}}
|
|
13
|
+
|
|
14
|
+With internal link opening in a new window:
|
|
15
|
+{{< external href="crypto-anarchist-manifesto.pdf" text="Manifesto" />}}
|
|
16
|
+
|
|
17
|
+With structured data type:
|
|
18
|
+{{< external itemtype="significantLink" href="https://habd.as" />}}
|
|
19
|
+
|
|
20
|
+With site-wide Referrer Policy overridden:
|
|
21
|
+{{< external referrerpolicy="unsafe-url" href="http://goo.gl" />}}
|
|
22
|
+
|
|
23
|
+With markdown image and link styling removed:
|
|
24
|
+{{% external href="https://source.unsplash.com/collection/983219/2160x1440" %}}
|
|
25
|
+ 
|
|
26
|
+{{% /external %}}
|
|
27
|
+
|
|
28
|
+Combined with button shortcode opening in same window with search query:
|
|
29
|
+{{< external target="_self" href="?s=query" >}}
|
|
30
|
+ {{< hackcss-button text="Default" />}}
|
|
31
|
+{{< /external >}}
|
|
32
|
+
|
|
33
|
+*/}} -->
|
|
34
|
+
|
|
35
|
+{{ $href := .Get "href" | default nil }}
|
|
36
|
+{{ $body := .Get "text" | default .Inner }}
|
|
37
|
+{{ $class := .Get "class" }}
|
|
38
|
+{{ $referrerpolicy := .Get "referrerpolicy" }}
|
|
39
|
+{{ $target := .Get "target" }}
|
|
40
|
+{{ $rel := .Get "rel" }}
|
|
41
|
+{{ $itemtype := .Get "itemtype" }}
|
|
42
|
+{{ if .IsNamedParams }}
|
|
43
|
+ {{ partial "components/external.html" (dict "href" $href "body" $body "class" $class "referrerpolicy" $referrerpolicy "target" $target "rel" $rel "itemtype" $itemtype "suppress_external" (and .Inner (eq (len (findRE "external" $rel)) 0))) }}
|
|
44
|
+{{ else }}
|
|
45
|
+ {{ partial "components/external.html" (dict "href" (.Get 0)) }}
|
|
46
|
+{{ end }}
|
|
47
|
+{{ if or (and .IsNamedParams (eq $href nil)) (and (eq .IsNamedParams false) (eq (.Get 0) nil)) }}
|
|
48
|
+ <p>{{ partial "components/alert.html" (dict "type" "error" "body" (errorf "Invalid use of external shortcode. Please provide an external link.")) }}</p>
|
|
49
|
+{{ end }}
|