Improved the definition of variables

Improved the definition of title, subtitle and image variables
This commit is contained in:
pmoreno.rodriguez 2023-02-03 22:30:08 +01:00 committed by GitHub
parent 11c82f8f60
commit 08e1b28e46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,9 @@
{% extends 'partials/base.html.twig' %}
{% set image = page.media[page.header.primaryImage] ?: page.media.images|first %}
{% set title = page.title|raw %}
{% set subtitle = page.header.subtitle|raw %}
{% block menu %}
{% include 'partials/sidebar_right.html.twig' %}
{% endblock %}
@ -8,17 +12,15 @@
<article class="post">
<header>
<div class="title">
<h2>{{ page.header.title }}</h2>
{% if page.header.subtitle %}
<p>{{ page.header.subtitle }}</p>
<h2>{{ title }}</h2>
{% if subtitle %}
<p>{{ subtitle }}</p>
{% endif %}
</div>
</header>
{% if page.header.primaryImage %}
{{ page.media[page.header.primaryImage].cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }}
{% else %}
{{ page.media.images|first.cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }}
{% if image %}
{{ image.cropZoom(1038,437).loading('lazy').html(title, title, 'image featured')|raw }}
{% endif %}
{{ page.content|raw }}