Added newtab option to file shortcode.
This commit is contained in:
parent
e9f8977861
commit
02efe4fdde
2 changed files with 7 additions and 5 deletions
|
|
@ -476,8 +476,9 @@ Creates a link to a file in static or in assets directory.
|
||||||
Possible parameters are:
|
Possible parameters are:
|
||||||
|
|
||||||
* class
|
* class
|
||||||
* name
|
* newtab (default false)
|
||||||
* src
|
* src
|
||||||
|
* text
|
||||||
|
|
||||||
|
|
||||||
### Search
|
### Search
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
{{ $class := .Get "class" -}}
|
{{ $class := .Get "class" -}}
|
||||||
{{ $name := .Get "name" -}}
|
{{ $newtab := .Get "newtab" | default false -}}
|
||||||
{{ $src := .Get "src" -}}
|
{{ $src := .Get "src" -}}
|
||||||
|
{{ $text := .Get "text" -}}
|
||||||
{{ if and $src (fileExists (add "/assets" $src)) -}}
|
{{ if and $src (fileExists (add "/assets" $src)) -}}
|
||||||
{{ $original := resources.Get $src -}}
|
{{ $original := resources.Get $src -}}
|
||||||
{{ $src = $original.RelPermalink -}}
|
{{ $src = $original.RelPermalink -}}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ if not $name -}}
|
{{ if not $text -}}
|
||||||
{{ $name = path.Base $src -}}
|
{{ $text = path.Base $src -}}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<a class="file{{ with $class }} {{ . }}{{ end }}" href="{{ $src }}">{{ $name }}</a>
|
<a class="file{{ with $class }} {{ . }}{{ end }}" href="{{ $src }}"{{ if $newtab }} target="_blank" rel="noopener noreferrer"{{ end }}>{{ $text }}</a>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue