Browse Source

feat(shortcodes): add type attribute for external links

provides hinting on mime when rel set to alternate
Josh Habdas 11 months ago
parent
commit
d80b1f33cf
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74
2 changed files with 4 additions and 3 deletions
  1. 1
    1
      layouts/partials/facets/external.html
  2. 3
    2
      layouts/shortcodes/external.html

+ 1
- 1
layouts/partials/facets/external.html View File

@@ -1 +1 @@
1
-<a {{ with .itemtype }} itemprop itemtype="http://schema.org/{{ . }}"{{ end }} target="{{ .target | default "_blank" }}"{{ with .rel }} rel="{{ . }}"{{ else }} rel="{{ if ne .supress_external true }}external{{ end }} noopener"{{ end }} href="{{ .href }}"{{ with .referrerpolicy }} referrerpolicy="{{ . }}"{{ end }}{{ with .class }} class="{{ . }}"{{ end }}>{{ .body | default (replaceRE "^https?://(.*)" "$1" .href) }}</a>
1
+<a {{ with .itemtype }} itemprop itemtype="http://schema.org/{{ . }}"{{ end }} target="{{ .target | default "_blank" }}"{{ with .type }} type="{{ . }}"{{ end }}{{ with .rel }} rel="{{ . }}"{{ else }} rel="{{ if ne .supress_external true }}external{{ end }} noopener"{{ end }} href="{{ .href }}"{{ with .referrerpolicy }} referrerpolicy="{{ . }}"{{ end }}{{ with .class }} class="{{ . }}"{{ end }}>{{ .body | default (replaceRE "^https?://(.*)" "$1" .href) }}</a>

+ 3
- 2
layouts/shortcodes/external.html View File

@@ -1,5 +1,5 @@
1 1
 <!-- {{/*
2
-HTML attributes: href [default: "#"], class, referrerpolicy, target [default: "_blank"], rel [default: "external noopener"]
2
+HTML attributes: href [default: "#"], class, referrerpolicy, target [default: "_blank"], type, rel [default: "external noopener"]
3 3
 Custom attributes: text [default: Inner], body [default: href], itemtype
4 4
 
5 5
 Basic usage:
@@ -37,10 +37,11 @@ Combined with button shortcode opening in same window with search query:
37 37
 {{ $class := .Get "class" }}
38 38
 {{ $referrerpolicy := .Get "referrerpolicy" }}
39 39
 {{ $target := .Get "target" }}
40
+{{ $type := .Get "type" }}
40 41
 {{ $rel := .Get "rel" }}
41 42
 {{ $itemtype := .Get "itemtype" }}
42 43
 {{ if .IsNamedParams }}
43
-  {{ partial "facets/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
+  {{ 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))) -}}
44 45
 {{ else }}
45 46
   {{ partial "facets/external.html" (dict "href" (.Get 0)) -}}
46 47
 {{ end -}}

Loading…
Cancel
Save