diff --git a/content/shortcodes.md b/content/shortcodes.md index 4fa0eb7..435702c 100644 --- a/content/shortcodes.md +++ b/content/shortcodes.md @@ -7,9 +7,20 @@ tags = ["showcase", "shortcodes"] ## Image shortcodes +### Dual theme images + +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") }} + +Usage: +``` +{{/* dual_theme_image(light_src="$BASE_URL/img/paris_day.webp", dark_src="$BASE_URL/img/paris_night.webp" alt="The Eiffel tower") */}} +``` + ### Invertible image -You can use this shortcode for graphs, line drawings, diagrams… +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") }} diff --git a/sass/parts/_image.scss b/sass/parts/_image.scss index bc54438..983e153 100644 --- a/sass/parts/_image.scss +++ b/sass/parts/_image.scss @@ -37,3 +37,16 @@ figure h4::before { svg { max-height: 15px; } + +.img-dark { + display: none; +} + +[data-theme="dark"] { + .img-dark { + display: block; + } + .img-light { + display: none; + } +} diff --git a/static/img/paris_day.webp b/static/img/paris_day.webp new file mode 100644 index 0000000..b61751a Binary files /dev/null and b/static/img/paris_day.webp differ diff --git a/static/img/paris_night.webp b/static/img/paris_night.webp new file mode 100644 index 0000000..a4f32a4 Binary files /dev/null and b/static/img/paris_night.webp differ diff --git a/templates/shortcodes/dual_theme_image.html b/templates/shortcodes/dual_theme_image.html new file mode 100644 index 0000000..cfb6a6d --- /dev/null +++ b/templates/shortcodes/dual_theme_image.html @@ -0,0 +1,2 @@ + +