Use external link policy for icon URLs
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
{{ $external := false }}
|
||||
{{ $target := partial "paige/target.html" (dict "page" .Page "url" .Destination) }}
|
||||
|
||||
{{ if (urls.Parse .Destination).IsAbs }}
|
||||
{{ $external = not (strings.HasSuffix .Destination site.BaseURL) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $newtab := and $external site.Params.paige.external_link_new_tab }}
|
||||
|
||||
<a {{ with .Destination }} href="{{ . }}" {{ end }} {{ if $newtab }} target="_blank" {{ end }} {{ with .Title }} title="{{ . }}" {{ end }}>{{ .Text }}</a>
|
||||
<a {{ with .Destination }} href="{{ . }}" {{ end }} {{ with $target }} target="{{ . }}" {{ end }} {{ with .Title }} title="{{ . }}" {{ end }}>{{ .Text }}</a>
|
||||
|
8
layouts/partials/paige/target.html
Normal file
8
layouts/partials/paige/target.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{{ $params := . }}
|
||||
|
||||
{{ $page := $params.page }}
|
||||
{{ $url := $params.url }}
|
||||
|
||||
{{ $external := cond (urls.Parse $url).IsAbs (not (strings.HasSuffix $url site.BaseURL)) false }}
|
||||
|
||||
{{ return cond (and $external ($page.Param "paige.external_link_new_tab" | not | not)) "_blank" "" }}
|
@@ -2,13 +2,15 @@
|
||||
{{ $title := .Get "title" }}
|
||||
{{ $url := .Get "url" }}
|
||||
|
||||
{{ $target := partial "paige/target.html" (dict "page" .Page "url" $url) }}
|
||||
|
||||
{{ if not $class }}
|
||||
{{ errorf "layouts/shortcodes/paige/icon.html: no class" }}
|
||||
{{ end }}
|
||||
|
||||
<span class="paige-icon">
|
||||
{{ with $url }}
|
||||
<a href="{{ . }}" {{ with $title }} title="{{ . }}" {{ end }}>
|
||||
<a href="{{ . }}" {{ with $target }} target="{{ . }}" {{ end }} {{ with $title }} title="{{ . }}" {{ end }}>
|
||||
{{ end }}
|
||||
|
||||
<i class="{{ $class }}">{{ with $title }}<span class="visually-hidden">{{ . }}</span>{{ end }}</i>
|
||||
|
Reference in New Issue
Block a user