🐛 fix(home-banner): allow missing image & correct spacing

Also allows using normal paths for the banner image, without "$BASE_URL".
This commit is contained in:
welpo 2023-08-29 15:19:00 +02:00
parent 7d8ed20c24
commit 00e1a8e80e
No known key found for this signature in database
GPG key ID: A2F978CF4EC1F5A6
6 changed files with 81 additions and 75 deletions

View file

@ -2,14 +2,24 @@
<div id="banner-container-home">
<div id="home-banner-text">
<div class="home-banner-header">{{ desc.title }}</div>
<div id="home-banner-header">{{ desc.title }}</div>
<section id="banner-home-subtitle">
{{ page.content | safe }}
</section>
</div>
<div class="image-container-home">
<img alt="the owner" class="banner-home-img" src={{ desc.img | replace(from="$BASE_URL", to=config.base_url) | safe}} />
</div>
{%- if desc.img -%}
{# Check if the image contains "$BASE_URL". This feature will be removed in the future #} {# in favour of using the proper image path. It will be a breaking change. #}
{%- if desc.img is containing("$BASE_URL") -%}
{%- set image_path = desc.img | replace(from="$BASE_URL", to=config.base_url) | safe -%}
{# When the feature is removed, uncomment below to throw a descriptive error #}
{# {{ throw(message="ERROR: The image path for the header should not contain '$BASE_URL'. Please remove it and use the proper image path.") }} #}
{%- else -%}
{%- set image_path = get_url(path=desc.img, trailing_slash=false) | safe -%}
{%- endif -%}
<div id="image-container-home">
<img alt="the owner" id="banner-home-img" src="{{ image_path }}" />
</div>
{%- endif -%}
</div>
{% endmacro %}