diff --git a/content/blog/mastering-tabi-settings/index.md b/content/blog/mastering-tabi-settings/index.md index 4a7b3cf2..49781782 100644 --- a/content/blog/mastering-tabi-settings/index.md +++ b/content/blog/mastering-tabi-settings/index.md @@ -415,6 +415,8 @@ invertible_image = false - `description` is the description of the project. - `weight` determines the order in which the projects are shown. The lower the weight, the higher the project will appear. - `local_image` is the path to the image of the project. This image is shown on the projects page. +- `local_image_dark` is an optional path to an alternative image to be shown in dark mode. When set, `local_image` is shown in light mode only. + - `remote_image` and `remote_image_dark` is an alternative which you can use when you want to set an URL instead. - `invertible_image` inverts the image colours in dark mode. Useful for black and white logos/icons. When a user clicks on the image or title of a project, they will be taken to the project's page. If you'd rather have users go to an external link, you can set `link_to = "https://example.com` in the `[extra]` section of the project's `.md` file. diff --git a/templates/macros/list_posts.html b/templates/macros/list_posts.html index 20761948..4e2eec91 100644 --- a/templates/macros/list_posts.html +++ b/templates/macros/list_posts.html @@ -97,21 +97,36 @@ {% if post.extra.local_image or post.extra.remote_image %}
  • + {% if post.extra.local_image %} + {% if post.extra.local_image_dark %} + {# Show light image only in light mode, dark image only in dark mode #} + {% set meta_dark = get_image_metadata(path=post.extra.local_image_dark, allow_missing=true) %} + {{ post.extra.local_image_dark }} + {% endif %} {% set meta = get_image_metadata(path=post.extra.local_image, allow_missing=true) %} - {{ post.extra.local_image }} {% elif post.extra.remote_image %} - {{ post.extra.remote_image_dark }} + {% endif %} + {{ post.extra.remote_image }} {% endif %} - -
  • - {% endif %} + {% endif %} {% if post.draft %}
  • {{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}
  • diff --git a/templates/partials/cards_pages.html b/templates/partials/cards_pages.html index b923b2c1..3f944108 100644 --- a/templates/partials/cards_pages.html +++ b/templates/partials/cards_pages.html @@ -20,14 +20,31 @@ {% endif %}> {% if page.extra.invertible_image %}{% set card_image_class = "card-image invertible-image" %}{% else %}{% set card_image_class = "card-image" %}{% endif %} {% if page.extra.local_image %} + {% if page.extra.local_image_dark %} + {# Show light image only in light mode, dark image only in dark mode #} + {% set meta_dark = get_image_metadata(path=page.extra.local_image_dark, allow_missing=true) %} + {{ page.extra.local_image_dark }} + {% endif %} {% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %} - {{ page.extra.local_image }} {% elif page.extra.remote_image %} - {{ page.extra.remote_image_dark }} + {% endif %} + {% set meta = get_image_metadata(path=page.extra.remote_image_dark, allow_missing=true) %} + {{ page.extra.remote_image }} {% else %}