public-web/layouts/shortcodes/file.html

12 lines
496 B
HTML

{{ $class := .Get "class" -}}
{{ $newtab := .Get "newtab" | default false -}}
{{ $src := .Get "src" -}}
{{ $text := .Get "text" -}}
{{ if and $src (fileExists (path.Join "/assets" $src)) -}}
{{ $original := resources.Get $src -}}
{{ $src = $original.RelPermalink -}}
{{ end -}}
{{ if not $text -}}
{{ $text = path.Base $src -}}
{{ end -}}
<a class="file{{ with $class }} {{ . }}{{ end }}" href="{{ $src }}"{{ if $newtab }} target="_blank" rel="noopener noreferrer"{{ end }}>{{ $text }}</a>