From 964b79a957e9d0f193625940acbb10a8863d79b8 Mon Sep 17 00:00:00 2001 From: tdro Date: Mon, 21 Nov 2022 19:42:16 -0500 Subject: themes/default/layouts/partials: Split favicon domain reference and fetch action into separate functions To help with template reuse and analysis --- .../layouts/partials/function-favicon-domain.html | 12 ++++++++++++ .../layouts/partials/function-fetch-favicons.html | 13 +++++++++++++ .../layouts/partials/function-generate-feeds.html | 19 +++++-------------- 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 themes/default/layouts/partials/function-favicon-domain.html create mode 100644 themes/default/layouts/partials/function-fetch-favicons.html diff --git a/themes/default/layouts/partials/function-favicon-domain.html b/themes/default/layouts/partials/function-favicon-domain.html new file mode 100644 index 0000000..f73ad62 --- /dev/null +++ b/themes/default/layouts/partials/function-favicon-domain.html @@ -0,0 +1,12 @@ +{{- $input := . -}} + +{{- $output := + (print + "https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=" + "http://" + $input + "&size=64" + ) +-}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/function-fetch-favicons.html b/themes/default/layouts/partials/function-fetch-favicons.html new file mode 100644 index 0000000..1d52c7e --- /dev/null +++ b/themes/default/layouts/partials/function-fetch-favicons.html @@ -0,0 +1,13 @@ +{{- $source := .Source -}} +{{- $infix := .Infix -}} + +{{- $output := partial "function-caches-images.html" + (dict + "Source" $source + "Fit" "160x160" + "Target" (print (partial "function-paths.html" "media") "/") + "Copy" (print (partial "function-paths.html" "media") "/favicon." $infix ".png") + ) +-}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/function-generate-feeds.html b/themes/default/layouts/partials/function-generate-feeds.html index e494596..87560fe 100644 --- a/themes/default/layouts/partials/function-generate-feeds.html +++ b/themes/default/layouts/partials/function-generate-feeds.html @@ -184,26 +184,17 @@ {{- $name := .FeedName -}} {{- $domain := .FeedSourceDomain -}} - {{- $faviconDomain := - (print - "https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=" - "http://" - .FeedSourceDomain - "&size=64" - ) - -}} + {{- $favicon := partial "function-favicon-domain.html" $domain -}} {{- with .FeedImageLink -}} - {{- $faviconDomain = . -}} + {{- $favicon = . -}} {{- $domain = $name | humanize | urlize -}} {{- end -}} - {{- $imageSource := partial "function-caches-images.html" + {{- $imageSource := partial "function-fetch-favicons.html" (dict - "Source" $faviconDomain - "Fit" "160x160" - "Target" (print (partial "function-paths.html" "media") "/") - "Copy" (print (partial "function-paths.html" "media") "/favicon." $domain ".png") + "Source" $favicon + "Infix" $domain ) -}} -- cgit v1.2.3