From 8dc49bac87fe07568bb3242aade8c2d366888e05 Mon Sep 17 00:00:00 2001 From: Apoorv Khandelwal Date: Sat, 21 Jan 2023 10:01:05 -0800 Subject: [PATCH] feat: Embedding multimodal assets (#274) --- layouts/partials/textprocessing.html | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html index 09e23181..c918247b 100644 --- a/layouts/partials/textprocessing.html +++ b/layouts/partials/textprocessing.html @@ -77,9 +77,31 @@ {{$href := printf "/%s/%s" $dirname $basename}} {{if (hasPrefix . "!")}} - {{$width := index $split 1}} - {{$link := printf "" $href (default "auto" $width)}} - {{$content = replace $content . $link}} + {{ $embed_ext := lower (path.Ext $href) }} + + {{if in ".png .jpg .jpeg .gif .bmp .svg" $embed_ext }} + {{$width := default "auto" (index $split 1) }} + {{$link := printf "" $href $width}} + {{$content = replace $content . $link}} + + {{else if in ".mp4 .webm .ogv .mov .mkv" $embed_ext}} + {{$link := printf "" $href}} + {{$content = replace $content . $link}} + + {{else if in ".mp3 .webm .wav .m4a .ogg .3gp .flac" $embed_ext}} + {{$link := printf "" $href}} + {{$content = replace $content . $link}} + + {{else if in ".pdf" $embed_ext }} + {{$src_link := printf "[source]" $href}} + {{$iframe_link := printf "" $href}} + {{$link := printf "%s
%s" $src_link $iframe_link}} + {{$content = replace $content . $link}} + + {{else}} + {{$link := printf "%s" $href $href}} + {{$content = replace $content . $link}} + {{end}} {{else}} {{$link := printf "%s" $href $display}} {{$content = replace $content . $link}}