Hugo Dark Theme Site Generator https://after-dark.habd.as
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

external.html 2.2KB

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