From 984d1a576c30134617f01df1933475188f033c14 Mon Sep 17 00:00:00 2001 From: parsiya Date: Fri, 24 Jul 2020 22:05:16 +0530 Subject: [PATCH] add blockquote as shortcode --- layouts/shortcodes/blockquote.html | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 layouts/shortcodes/blockquote.html diff --git a/layouts/shortcodes/blockquote.html b/layouts/shortcodes/blockquote.html new file mode 100644 index 00000000..14bb107a --- /dev/null +++ b/layouts/shortcodes/blockquote.html @@ -0,0 +1,72 @@ + + + + + +{{ $.Scratch.Set "bl_author" false }} +{{ $.Scratch.Set "bl_source" false }} +{{ $.Scratch.Set "bl_link" false }} +{{ $.Scratch.Set "bl_title" false }} + +{{ if .IsNamedParams }} + {{ $.Scratch.Set "bl_author" (.Get "author") }} + {{ $.Scratch.Set "bl_source" (.Get "source") }} + {{ $.Scratch.Set "bl_link" (.Get "link") }} + {{ $.Scratch.Set "bl_title" (.Get "title") }} +{{ else }} + +{{ end }} + + + +{{ with $.Scratch.Get "bl_title" }} + +{{ else }} + {{ with $.Scratch.Get "bl_link" }} + {{ range last 1 (split ($.Scratch.Get "bl_link" ) "://") }} + {{ $.Scratch.Set "title_without_protocol" . }} + {{ end }} + {{ range last 1 (split ($.Scratch.Get "title_without_protocol" ) "www.") }} + {{ $.Scratch.Set "title_without_protocol" . }} + {{ end }} + {{ $.Scratch.Set "bl_title" ($.Scratch.Get "title_without_protocol") }} + + + {{ if (gt (len ($.Scratch.Get "title_without_protocol") ) 32) }} + {{ $title := (slicestr ($.Scratch.Get "title_without_protocol") 0 32) }} + {{ $split_by_fw_slash := split $title "/" }} + {{ $count := (sub (len $split_by_fw_slash) 1) }} + + {{ $.Scratch.Set "tempstring" "" }} + {{ range first $count $split_by_fw_slash }} + {{ $.Scratch.Set "tempstring" ( . | printf "%s%s/" ($.Scratch.Get "tempstring") | printf "%s" ) }} + {{ end }} + {{ $.Scratch.Set "bl_title" ( printf "%s..." ($.Scratch.Get "tempstring") | printf "%s" ) }} + {{ end }} + {{ end }} +{{ end }} + +
+

{{ .Inner | markdownify }}

+ +