Added new file shortcode and added better checks in figure and img shortcodes.
This commit is contained in:
parent
507394c93d
commit
46595e5ae9
1 changed files with 30 additions and 5 deletions
11
layouts/shortcodes/file.html
Normal file
11
layouts/shortcodes/file.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{{ $class := .Get "class" -}}
|
||||
{{ $name := .Get "name" -}}
|
||||
{{ $src := .Get "src" -}}
|
||||
{{ if and $src (fileExists (add "/assets" $src)) -}}
|
||||
{{ $original := resources.Get $src -}}
|
||||
{{ $src = $original.RelPermalink -}}
|
||||
{{ end -}}
|
||||
{{ if not $name -}}
|
||||
{{ $name = path.Base $src -}}
|
||||
{{ end -}}
|
||||
<a class="file{{ with $class }} {{ . }}{{ end }}" href="{{ $src }}">{{ $name }}</a>
|
||||
Loading…
Reference in a new issue