From 02efe4fdde5c11d836aa3e40a59832252f16626b Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Wed, 25 Nov 2020 08:55:57 +0100 Subject: [PATCH] Added newtab option to file shortcode. --- README.md | 3 ++- layouts/shortcodes/file.html | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9b991bd..178bb2c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/layouts/shortcodes/file.html b/layouts/shortcodes/file.html index 3c76699..c52f532 100644 --- a/layouts/shortcodes/file.html +++ b/layouts/shortcodes/file.html @@ -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 -}} -{{ $name }} +{{ $text }}