Browse Source

feat(shortcodes): add title attr to external

Josh Habdas 1 year ago
parent
commit
ce451e4f17
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 .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>
1
+<a {{ with .itemtype }} itemprop itemtype="http://schema.org/{{ . }}"{{ end }} target="{{ .target | default "_blank" }}"{{ with .type }} type="{{ . }}"{{ end }}{{ with .title }} title="{{ . }}"{{ 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"], "type", "rel" [default: "external noopener"]
2
+HTML attributes: "href" [default: "#"], "class", "referrerpolicy", "target" [default: "_blank"], "type", "title", "rel" [default: "external noopener"]
3 3
 Custom attributes: "text" [default: Inner], "itemtype"
4 4
 
5 5
 Basic usage:
@@ -37,11 +37,12 @@ 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
+{{ $title := .Get "title" }}
40 41
 {{ $type := .Get "type" }}
41 42
 {{ $rel := .Get "rel" }}
42 43
 {{ $itemtype := .Get "itemtype" }}
43 44
 {{ if .IsNamedParams }}
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))) -}}
45
+  {{ partial "facets/external.html" (dict "href" $href "body" $body "class" $class "referrerpolicy" $referrerpolicy "target" $target "type" $type "title" $title "rel" $rel "itemtype" $itemtype "suppress_external" (and .Inner (eq (len (findRE "external" $rel)) 0))) -}}
45 46
 {{ else }}
46 47
   {{ partial "facets/external.html" (dict "href" (.Get 0)) -}}
47 48
 {{ end -}}

Loading…
Cancel
Save