Added new file shortcode and added better checks in figure and img shortcodes.

This commit is contained in:
Fredrik Jonsson 2020-11-23 11:08:12 +01:00
commit 46595e5ae9

View 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>