This commit is contained in:
Poolitzer 2025-12-12 23:00:18 +01:00 committed by GitHub
commit 0dbdb63bc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 2 deletions

View file

@ -414,6 +414,7 @@ local_image = "img/tabi.webp"
- `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.
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.

View file

@ -98,8 +98,17 @@
<li class="post-thumbnail">
<a href="{{ post.permalink }}">
{% 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) %}
<img class="thumbnail-image img-dark"
alt="{{ post.extra.local_image_dark }}"
src="{{ get_url(path=post.extra.local_image_dark) }}"
{% if meta_dark.width %}width="{{ meta_dark.width }}"{% endif %}
{% if meta_dark.height %}height="{{ meta_dark.height }}"{% endif %}>
{% endif %}
{% set meta = get_image_metadata(path=post.extra.local_image, allow_missing=true) %}
<img class="thumbnail-image"
<img class="thumbnail-image{% if page.extra.local_image_dark %} img-light{% endif %}"
alt="{{ post.extra.local_image }}"
src="{{ get_url(path=post.extra.local_image) }}"
{% if meta.width %}width="{{ meta.width }}"{% endif %}

View file

@ -19,8 +19,17 @@
data-tags="{% for tax_name, terms in page.taxonomies %}{% for term in terms | unique %}{{ term | lower }}{% if not loop.last %},{% endif %}{% endfor %}{% endfor %}"
{% 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) %}
<img class="card-image img-dark"
alt="{{ page.extra.local_image_dark }}"
src="{{ get_url(path=page.extra.local_image_dark) }}"
{% if meta_dark.width %}width="{{ meta_dark.width }}"{% endif %}
{% if meta_dark.height %}height="{{ meta_dark.height }}"{% endif %}>
{% endif %}
{% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %}
<img class="card-image"
<img class="card-image{% if page.extra.local_image_dark %} img-light{% endif %}"
alt="{{ page.extra.local_image }}"
src="{{ get_url(path=page.extra.local_image) }}"
{% if meta.width %}width="{{ meta.width }}"{% endif %}