Harmonize and modify twigs

This commit is contained in:
pikim 2022-12-20 00:17:26 +01:00
parent 2f644cfa1a
commit 9dc080bed8
4 changed files with 157 additions and 170 deletions

View file

@ -1,49 +1,51 @@
{% embed 'partials/base.html.twig' %} {% extends 'partials/base.html.twig' %}
{% set collection = page.collection() %} {% set collection = page.collection() %}
{% set base_url = page.url %} {% set base_url = page.url %}
{% set feed_url = base_url %} {% set feed_url = base_url %}
{% if page.header.show_breadcrumbs is defined %} {% if page.header.show_breadcrumbs is defined %}
{% set show_breadcrumbs = page.header.show_breadcrumbs %} {% set show_breadcrumbs = page.header.show_breadcrumbs %}
{% else %} {% else %}
{% set show_breadcrumbs = true %} {% set show_breadcrumbs = true %}
{% endif %} {% endif %}
{% if page.header.show_pagination is defined %} {% if page.header.show_pagination is defined %}
{% set show_pagination = page.header.show_pagination %} {% set show_pagination = page.header.show_pagination %}
{% else %} {% else %}
{% set show_pagination = true %} {% set show_pagination = true %}
{% endif %} {% endif %}
{% if base_url == '/' %} {% if base_url == '/' %}
{% set base_url = '' %} {% set base_url = '' %}
{% endif %}
{% if base_url == base_url_relative %}
{% set feed_url = base_url~'/'~page.slug %}
{% endif %}
{% block menu %}
{% include 'partials/sidebar_right.html.twig' %}
{% endblock %}
{% block content %}
{% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %}
{% include 'partials/breadcrumbs.html.twig' %}
{% endif %}
{#
{% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %}
{% include 'partials/pagination.html.twig' with {base_url: page.url, pagination: collection.params.pagination} %}
{% endif %}
#}
{% for child in collection %}
{% if child.header.hide is not defined or not child.header.hide %}
{% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %}
{% endif %}
{% endfor %}
{% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %}
{% include 'partials/pagination.html.twig' with {base_url: page.url, pagination: collection.params.pagination} %}
{% endif %} {% endif %}
{% if base_url == base_url_relative %} <section id="footer" class="align-center">
{% set feed_url = base_url~'/'~page.slug %} {% include 'partials/footer.html.twig' %}
{% endif %} </section>
{% endblock %}
{% block menu %}
{% include 'partials/sidebar_right.html.twig' %}
{% endblock %}
{% block content %}
{% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %}
{% include 'partials/breadcrumbs.html.twig' %}
{% endif %}
{% for child in collection %}
{% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %}
{% endfor %}
{% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %}
{% include 'partials/pagination.html.twig' with {base_url: page.url, pagination: collection.params.pagination} %}
{% endif %}
{% endblock %}
{% block sidebar %}
{% include 'partials/sidebar_left.html.twig' %}
{% endblock %}
{% endembed %}

View file

@ -1,34 +1,33 @@
{% extends 'partials/base.html.twig' %} {% extends 'partials/base.html.twig' %}
{% if page.header.show_breadcrumbs is defined %}
{% set show_breadcrumbs = page.header.show_breadcrumbs %}
{% else %}
{% set show_breadcrumbs = true %}
{% endif %}
{% block menu %} {% block menu %}
{% include 'partials/sidebar_right.html.twig' %} {% include 'partials/sidebar_right.html.twig' %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<article class="post"> {% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %}
<header> {% include 'partials/breadcrumbs.html.twig' %}
<div class="title"> {% endif %}
<h2>{{ page.header.title }}</h2>
{% if page.header.subtitle %}
<p>{{ page.header.subtitle }}</p>
{% endif %}
</div>
</header> <article class="post">
{% if page.header.primaryImage %} <header>
{{ page.media[page.header.primaryImage].cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} <div class="title">
{% else %} <h2>{{ page.header.title }}</h2>
{{ page.media.images|first.cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} {% if page.header.subtitle %}
{% endif %} <p>{{ page.header.subtitle }}</p>
{{ page.content|raw}} {% endif %}
</div>
</article> </header>
<section id="footer" class="align-center"> {{ page.content|raw }}
{% block footer %} </article>
{% include 'partials/footer.html.twig' %}
{% endblock %} <section id="footer" class="align-center">
</section> {% include 'partials/footer.html.twig' %}
</section>
{% endblock %} {% endblock %}

View file

@ -1,31 +1,23 @@
{% embed 'partials/base.html.twig' %} {% extends 'partials/base.html.twig' %}
{% set base_url = page.parent.url %}
{% set feed_url = base_url %}
{% set show_breadcrumbs = header_var('show_breadcrumbs', [page, blog]) %}
{% if base_url == '/' %} {% if page.header.show_breadcrumbs is defined %}
{% set base_url = '' %} {% set show_breadcrumbs = page.header.show_breadcrumbs %}
{% else %}
{% set show_breadcrumbs = true %}
{% endif %}
{% block menu %}
{% include 'partials/sidebar_right.html.twig' %}
{% endblock %}
{% block content %}
{% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %}
{% include 'partials/breadcrumbs.html.twig' %}
{% endif %} {% endif %}
{% if base_url == base_url_relative %} {% include 'partials/blog_item.html.twig' with {'truncate':false} %}
{% set feed_url = base_url~'/'~page.parent.slug %}
{% endif %}
{% block menu %}
{% include 'partials/sidebar_right.html.twig' %}
{% endblock %}
{% block content %} <section id="footer" class="align-center">
{% include 'partials/footer.html.twig' %}
{% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %} </section>
{% include 'partials/breadcrumbs.html.twig' %} {% endblock %}
{% endif %}
{% include 'partials/blog_item.html.twig' with {'truncate':false} %}
<section id="footer" class="align-center">
{% include 'partials/footer.html.twig' %}
</section>
{% endblock %}
{% endembed %}

View file

@ -1,93 +1,87 @@
<article class="post" itemprop="liveBlogUpdate" itemscope itemtype="http://schema.org/BlogPosting"> <article class="post" itemprop="liveBlogUpdate" itemscope itemtype="http://schema.org/BlogPosting">
{% if page.header.author %} {% if page.header.author %}
{% set author = page.header.author %} {% set author = page.header.author %}
{% else %} {% else %}
{% set author = page.header.taxonomy.author[0] %} {% set author = page.header.taxonomy.author[0] %}
{% endif %} {% endif %}
{% if author %} {% if author %}
{% set avatar = author|replace(' ', '-')|lower %} {% set avatar = author|replace(' ', '-')|lower %}
{% endif %} {% endif %}
<header> <header>
<div class="title"> <div class="title">
{% if page.header.link %} {% if page.header.link %}
<h2 itemprop="headline"> <h2 itemprop="headline">
{% if page.header.continue_link is not sameas(false) %} {% if page.header.continue_link is not sameas(false) %}
<a href="{{ page.url }}"></a> <a href="{{ page.url }}"></a>
{% endif %}
<a href="{{ page.header.link }}">{{ page.title }}</a>
</h2>
{% else %}
<h2 itemprop="headline"><a href="{{ page.url }}">{{ page.title }}</a></h2>
{% endif %}
{% if page.header.subtitle %}
<p itemprop="alternativeHeadline">{{ page.header.subtitle|raw }}</p>
{% endif %} {% endif %}
<a href="{{ page.header.link }}">{{ page.title }}</a>
</h2>
{% else %}
<h2 itemprop="headline"><a href="{{ page.url }}">{{ page.title }}</a></h2>
{% endif %}
{% if page.header.subtitle %}
<p itemprop="alternativeHeadline">{{ page.header.subtitle|raw }}</p>
{% endif %}
</div> </div>
<div class="meta"> <div class="meta">
<time class="published" itemprop="datePublished" datetime="{{page.date|date("Y-m-d")}}">{{ page.date|date("M j, Y")}}</time> <time class="published" itemprop="datePublished" datetime="{{page.date|dateTranslate(grav.config.system.pages.dateformat.short)}}">{{ page.date|dateTranslate(grav.config.system.pages.dateformat.short)}}</time>
{% if author %} {% if author %}
<a href="{{ base_url }}/author{{ config.system.param_sep }}{{ author }}" itemprop="keywords" class="author">{{ tag }}<span class="name" rel="author">{{ author }}</span>{% if page.header.avatarImage %}<img src="{{ page.media[page.header.avatarImage].url|e}}" alt="{{ author }}" />{% endif %}</a> <a href="{{ base_url }}/author{{ config.system.param_sep }}{{ author }}" itemprop="keywords" class="author">{{ tag }}<span class="name" rel="author">{{ author }}</span>{% if page.header.avatarImage %}<img src="{{ page.media[page.header.avatarImage].url|e}}" alt="{{ author }}" />{% endif %}</a>
{% endif %} {% endif %}
</div> </div>
</header> </header>
{% if page.header.primaryImage %} {% if page.header.primaryImage %}
<a href="{{ page.url }}" class="image featured">{{ page.media[page.header.primaryImage].cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }}</a> <a href="{{ page.url }}" class="image featured">{{ page.media[page.header.primaryImage].cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }}</a>
{% else %} {% elseif page.media.images %}
<a href="{{ page.url }}" class="image featured">{{ page.media.images|first.cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }}</a> <a href="{{ page.url }}" class="image featured">{{ page.media.images|first.cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }}</a>
{% endif %} {% endif %}
{% if page.header.blog_hide_body is not defined or not page.header.blog_hide_body %}
<div itemprop="articleBody"> <div itemprop="articleBody">
{% if page.header.continue_link is sameas(false) %}
{% if page.header.continue_link is sameas(false) %} {{ page.content|raw }}
{{ page.content|raw }} {% if not truncate %}
{% if not truncate %} {% set show_prev_next = true %}
{% set show_prev_next = true %} {% endif %}
{% endif %} {% elseif truncate and page.summary != page.content %}
{% elseif truncate and page.summary != page.content %} {{ page.summary|raw }}
{{ page.summary|raw }} {% elseif truncate %}
{% elseif truncate %} {{ page.content|truncate(550)|raw }}
{{ page.content|truncate(550)|raw }} {% else %}
{% else %} {{ page.content|raw }}
{{ page.content|raw }} {% set show_prev_next = true %}
{% set show_prev_next = true %} {% endif %}
{% endif %} </div>
{% endif %}
</div> <footer>
<footer>
<ul class="actions"> <ul class="actions">
{% if truncate and page.summary != page.content %} {% if truncate and page.summary != page.content %}
<li><a href="{{ page.url }}" class="button">{{'FUTURE.BLOG.ITEM.CONTINUE_READING'|t}}</a></li> <li><a href="{{ page.url }}" class="button">{{'FUTURE.BLOG.ITEM.CONTINUE_READING'|t}}</a></li>
{% elseif truncate %} {% elseif truncate %}
<li><a href="{{ page.url }}" class="button">{{'FUTURE.BLOG.ITEM.CONTINUE_READING'|t}}</a></li> <li><a href="{{ page.url }}" class="button">{{'FUTURE.BLOG.ITEM.CONTINUE_READING'|t}}</a></li>
{% endif %} {% endif %}
{% if show_prev_next %} {% if show_prev_next %}
{% if not page.isLast %} {% if not page.isLast %}
<li><a class="button" href="{{ page.prevSibling.url }}"><i class="fa fa-chevron-left"></i> {{'FUTURE.BLOG.ITEM.PREV_POST'|t}}</a></li> <li><a class="button" href="{{ page.prevSibling.url }}"><i class="fa fa-chevron-left"></i> {{'FUTURE.BLOG.ITEM.PREV_POST'|t}}</a></li>
{% endif %} {% endif %}
{% if not page.isFirst %} {% if not page.isFirst %}
<li><a class="button" href="{{ page.nextSibling.url }}">{{'FUTURE.BLOG.ITEM.NEXT_POST'|t}} <i class="fa fa-chevron-right"></i></a></li> <li><a class="button" href="{{ page.nextSibling.url }}">{{'FUTURE.BLOG.ITEM.NEXT_POST'|t}} <i class="fa fa-chevron-right"></i></a></li>
{% endif %} {% endif %}
{% endif %} {% endif %}
</ul> </ul>
<ul class="stats"> <ul class="stats">
{% if page.taxonomy.tag %} {% if page.taxonomy.tag %}
{% for tag in page.taxonomy.tag %} {% for tag in page.taxonomy.tag %}
<li><a href="{{ base_url }}/tag{{ config.system.param_sep }}{{ tag }}" itemprop="keywords">{{ tag }}</a></li> <li><a href="{{ base_url }}/tag{{ config.system.param_sep }}{{ tag }}" itemprop="keywords">{{ tag }}</a></li>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<li><a href="https://twitter.com/share" data-url="{{ page.url(true) }}" data-text="{{ page.title }}" class="icon brands fa-twitter"> <li><a href="https://twitter.com/share" data-url="{{ page.url(true) }}" data-text="{{ page.title }}" class="icon brands fa-twitter"></a></li>
</a></li> <li><a href="http://www.facebook.com/sharer.php?u={{ page.url(true) }}" class="icon brands fa-facebook"></a></li>
<li><a href="http://www.facebook.com/sharer.php?u={{ page.url(true) }}" class="icon brands fa-facebook">
</a></li>
</ul> </ul>
</footer> </footer>
</article> </article>