diff --git a/content/blog/shortcodes.md b/content/blog/shortcodes.md index fbc0afd..644a2b7 100644 --- a/content/blog/shortcodes.md +++ b/content/blog/shortcodes.md @@ -1,7 +1,7 @@ +++ title = "Custom shortcodes" date = 2023-02-19 -updated = 2023-03-11 +updated = 2023-04-16 description = "This theme includes some useful custom shortcodes that you can use to enhance your posts. Whether you want to display images that adapt to light and dark themes, or format a professional-looking reference section, these custom shortcodes have got you covered." [taxonomies] @@ -14,34 +14,35 @@ tags = ["showcase", "shortcodes"] Useful if you want to use a different image for the light and dark themes: -{{ dual_theme_image(light_src="$BASE_URL/img/paris_day.webp", dark_src="$BASE_URL/img/paris_night.webp" alt="The Eiffel tower") }} +{{ dual_theme_image(light_src="img/paris_day.webp", dark_src="img/paris_night.webp" alt="The Eiffel tower") }} #### Usage ``` -{{/* dual_theme_image(light_src="$BASE_URL/img/paris_day.webp", dark_src="$BASE_URL/img/paris_night.webp" alt="The Eiffel tower") */}} +{{/* dual_theme_image(light_src="img/paris_day.webp", dark_src="img/paris_night.webp" alt="The Eiffel tower") */}} ``` ### Invertible image Good for graphs, line drawings, diagrams… Inverts the colours of the image. The source image will be used for the light theme. -{{ invertible_image(src="$BASE_URL/img/graph.webp", alt="Invertible graph") }} +{{ invertible_image(src="img/graph.webp", alt="Invertible graph") }} #### Usage + ``` -{{/* invertible_image(src="$BASE_URL/img/graph.webp", alt="Invertible graph") */}} +{{/* invertible_image(src="img/graph.webp", alt="Invertible graph") */}} ``` ### Dimmable image Images with too much brightness or contrast can be jarring against a dark background. Here's an example of a photograph that dims when the dark theme is active. -{{ dimmable_image(src="$BASE_URL/img/desert_by_oskerwyld.webp", alt="Photograph of a desert, heavenly sky") }} +{{ dimmable_image(src="img/desert_by_oskerwyld.webp", alt="Photograph of a desert, heavenly sky") }} #### Usage ``` -{{/* dimmable_image(src="$BASE_URL/img/desert_by_oskerwyld.webp", alt="Photograph of a desert, heavenly sky") */}} +{{/* dimmable_image(src="img/desert_by_oskerwyld.webp", alt="Photograph of a desert, heavenly sky") */}} ``` ## References diff --git a/static/img/paris_day.webp b/static/img/paris_day.webp index b61751a..5dc219c 100644 Binary files a/static/img/paris_day.webp and b/static/img/paris_day.webp differ diff --git a/static/img/paris_night.webp b/static/img/paris_night.webp index a4f32a4..d445112 100644 Binary files a/static/img/paris_night.webp and b/static/img/paris_night.webp differ diff --git a/templates/shortcodes/dimmable_image.html b/templates/shortcodes/dimmable_image.html index d3d9621..05304f9 100644 --- a/templates/shortcodes/dimmable_image.html +++ b/templates/shortcodes/dimmable_image.html @@ -1 +1,2 @@ - +{% set meta = get_image_metadata(path=src) %} + diff --git a/templates/shortcodes/dual_theme_image.html b/templates/shortcodes/dual_theme_image.html index cfb6a6d..d97ea2a 100644 --- a/templates/shortcodes/dual_theme_image.html +++ b/templates/shortcodes/dual_theme_image.html @@ -1,2 +1,4 @@ - - +{% set light_meta = get_image_metadata(path=light_src) %} +{% set dark_meta = get_image_metadata(path=dark_src) %} + + diff --git a/templates/shortcodes/invertible_image.html b/templates/shortcodes/invertible_image.html index b204fde..25d3c66 100644 --- a/templates/shortcodes/invertible_image.html +++ b/templates/shortcodes/invertible_image.html @@ -1 +1,2 @@ - +{% set meta = get_image_metadata(path=src) %} +