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:
|
||||
|
||||
* class
|
||||
* name
|
||||
* newtab (default false)
|
||||
* src
|
||||
* text
|
||||
|
||||
|
||||
### Search
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
{{ $class := .Get "class" -}}
|
||||
{{ $name := .Get "name" -}}
|
||||
{{ $newtab := .Get "newtab" | default false -}}
|
||||
{{ $src := .Get "src" -}}
|
||||
{{ $text := .Get "text" -}}
|
||||
{{ if and $src (fileExists (add "/assets" $src)) -}}
|
||||
{{ $original := resources.Get $src -}}
|
||||
{{ $src = $original.RelPermalink -}}
|
||||
{{ end -}}
|
||||
{{ if not $name -}}
|
||||
{{ $name = path.Base $src -}}
|
||||
{{ if not $text -}}
|
||||
{{ $text = path.Base $src -}}
|
||||
{{ 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