aboutsummaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorCaio Lente <7017340+clente@users.noreply.github.com>2024-02-06 13:55:31 -0300
committerCaio Lente <7017340+clente@users.noreply.github.com>2024-02-06 13:55:31 -0300
commit116e87f7d0f0983da1530ddb8831c070d3b147f5 (patch)
tree2583187c9ad611a184601e1ceb42ba7206c0480e /layouts
parent58693036cfc0f9307c5ed9fdb381266cbbb57cae (diff)
downloadhugo-bearcub-116e87f7d0f0983da1530ddb8831c070d3b147f5.tar.gz
hugo-bearcub-116e87f7d0f0983da1530ddb8831c070d3b147f5.tar.bz2
Heuristic for reducing font size on social cards with long titles
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/social_card.html15
1 files changed, 13 insertions, 2 deletions
diff --git a/layouts/partials/social_card.html b/layouts/partials/social_card.html
index 6faacc0..d171da0 100644
--- a/layouts/partials/social_card.html
+++ b/layouts/partials/social_card.html
@@ -3,14 +3,25 @@
{{ $fg := resources.Get "images/social_card_fg.png"}}
{{ $bg := resources.Get "images/social_card_bg.png"}}
-{{ $fg = $fg.Filter (images.Text .Title (dict
+{{ if gt (len .Title) 45 }}
+ {{ $fg = $fg.Filter (images.Text .Title (dict
+ "font" $font
+ "color" "#fafafa"
+ "size" 95
+ "linespacing" 16
+ "x" 0
+ "y" 0
+ )) }}
+{{ else }}
+ {{ $fg = $fg.Filter (images.Text .Title (dict
"font" $font
"color" "#fafafa"
"size" 130
"linespacing" 20
"x" 0
"y" 0
-)) }}
+ )) }}
+{{ end }}
{{ $date := .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
{{ $author := (default $.Site.Params.author.name ($.Param "author") ) }}