From 9fc4b73a36721caeea48455b2c089dd476a00ecf Mon Sep 17 00:00:00 2001 From: Cyrill Raccaud Date: Mon, 21 Oct 2024 09:57:39 +0200 Subject: [PATCH] theme(fix): header image positioning (#731) Currently, the header image for a post is `bg-top`, but it would be nice the control this behavior to lets say `top|center|bottom`, as often the interesting part of an image is in the center. Using the `featured_image_class` param, one can now customize the class to control the alignment of the featured header image. It is also possible to add additional classes for further customization if needed. Default case: Bildschirmfoto 2024-10-12 um 14 23 10 Same as default case but set explicitly `featured_image_class = cover bg-top`: Bildschirmfoto 2024-10-12 um 14 23 10 `featured_image_class = cover bg-center`: Bildschirmfoto 2024-10-12 um 14 23 27 `featured_image_class = cover bg-bottom`: Bildschirmfoto 2024-10-12 um 14 23 36 `featured_image_class = contain bg-top`: Bildschirmfoto 2024-10-12 um 14 29 16 **Code formatting** **Closing issues** Closes #729 --- README.md | 4 ++++ exampleSite/config.toml | 2 ++ layouts/partials/page-header.html | 2 +- layouts/partials/site-header.html | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 15a4fa9b8..7c4e038b1 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,10 @@ You don't need an image though. The default background color is black, but you c example: `background_color_class = "bg-blue"` or `background_color_class = "bg-gray"` +The default fitting and alignment for th featured image is `cover bg-top`, but can be changed using the `featured_image_class`. Choose an fitting and alignment style for the featured image using tachyons classes such as "cover|contain" for fitting and "bg-top|bg-center|bg-bottom" for alignment. + +example: `featured_image_class = "cover bg-center"` or `featured_image_class = "contain bg-top"` + ### Activate the contact form This theme includes a shortcode for a contact form that you can add to any page (there is an example on the contact page in the exampleSite folder). One option is to use [formspree.io](//formspree.io/) as proxy to send the actual email. Each month, visitors can send you up to one thousand emails without incurring extra charges. Visit the Formspree site to get the "action" link and add it to your shortcode like this: diff --git a/exampleSite/config.toml b/exampleSite/config.toml index f167ad7a6..53a2299db 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -36,6 +36,8 @@ site_logo = "" description = "The last theme you'll ever need. Maybe." # choose a background color from any on this page: https://tachyons.io/docs/themes/skins/ and preface it with "bg-" background_color_class = "bg-black" +# choose an fitting and alignment style for the featured image using tachyons classes such as "cover|contain" for fitting and "bg-top|bg-center|bg-bottom" for alignment, or add any other class space-separated to customize further +featured_image_class = "cover bg-top" recent_posts_number = 3 [ananke.social.follow] diff --git a/layouts/partials/page-header.html b/layouts/partials/page-header.html index 3891c4598..51eb0e1ac 100644 --- a/layouts/partials/page-header.html +++ b/layouts/partials/page-header.html @@ -1,7 +1,7 @@ {{ $featured_image := partial "func/GetFeaturedImage.html" . }} {{ if $featured_image }} {{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}} -
+
{{ partial "site-navigation.html" . }}
diff --git a/layouts/partials/site-header.html b/layouts/partials/site-header.html index 1a0b3cb2e..7a121fb3e 100644 --- a/layouts/partials/site-header.html +++ b/layouts/partials/site-header.html @@ -1,7 +1,7 @@ {{ $featured_image := partial "func/GetFeaturedImage.html" . }} {{ if $featured_image }} {{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}} -
+
{{ partial "site-navigation.html" .}}