Fixed support for the twig-extensions plugin

This commit is contained in:
Pedro Moreno 2023-02-25 22:53:57 +01:00
parent 047a6da40c
commit 131b6ae197
2 changed files with 18 additions and 10 deletions

View file

@ -1,3 +1,5 @@
{% set lang = grav.language.getActive ?: grav.config.site.default_lang %}
{% extends 'partials/base.html.twig' %} {% extends 'partials/base.html.twig' %}
{% block content %} {% block content %}
<article class="post"> <article class="post">
@ -8,6 +10,8 @@
<div class="meta"> <div class="meta">
{% if config.plugins["translate-date"].enabled %} {% if config.plugins["translate-date"].enabled %}
<time class="published" datetime="{{ form.date|td(null, "Y-m-d") }}">{{ form.date|td(null, "M j, Y") }}</time> <time class="published" datetime="{{ form.date|td(null, "Y-m-d") }}">{{ form.date|td(null, "M j, Y") }}</time>
{% elseif config.plugins["twig-extensions"].enabled %}
<time class="published" datetime="{{ form.date|localizeddate('medium', 'none', lang) }}">{{ form.date|localizeddate('medium', 'none', lang) }}</time>
{% else %} {% else %}
<time class="published" datetime="{{ form.date|date("Y-m-d") }}">{{ form.date|date("M j, Y") }}</time> <time class="published" datetime="{{ form.date|date("Y-m-d") }}">{{ form.date|date("M j, Y") }}</time>
{% endif %} {% endif %}

View file

@ -1,3 +1,5 @@
{% set lang = grav.language.getActive ?: grav.config.site.default_lang %}
<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.metadata.author %} {% if page.header.metadata.author %}
@ -17,13 +19,13 @@
{% 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 }}" aria-label="{{ title }}"></a>
{% endif %} {% endif %}
<a href="{{ page.header.link }}">{{ page.title }}</a> <a href="{{ page.header.link }}" aria-label="{{ title }}">{{ title }}</a>
</h2> </h2>
{% else %} {% else %}
<h2 itemprop="headline"> <h2 itemprop="headline">
<a href="{{ page.url }}">{{ page.title }}</a> <a href="{{ page.url }}" aria-label="{{ title }}">{{ title }}</a>
</h2> </h2>
{% endif %} {% endif %}
{% if page.header.subtitle %} {% if page.header.subtitle %}
@ -33,12 +35,14 @@
<div class="meta"> <div class="meta">
{% if config.plugins["translate-date"].enabled %} {% if config.plugins["translate-date"].enabled %}
<time class="published" itemprop="datePublished" datetime="{{ page.date|td(null, "Y-m-d") }}">{{ page.date|td(null, "M j, Y") }}</time> <time class="published" itemprop="datePublished" datetime="{{ page.date|td(null, "Y-m-d") }}">{{ page.date|td(null, "M j, Y") }}</time>
{% elseif config.plugins["twig-extensions"].enabled %}
<time class="published" itemprop="datePublished" datetime="{{ page.date|localizeddate('medium', 'none', lang) }}">{{ page.date|localizeddate('medium', 'none', lang) }}</time>
{% else %} {% else %}
<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|date("Y-m-d") }}">{{ page.date|date("M j, Y") }}</time>
{% endif %} {% endif %}
{% if author %} {% if author %}
<span itemprop="author" itemscope itemtype="http://schema.org/Person"/> <span itemprop="author" itemscope itemtype="http://schema.org/Person"/>
<a {% if page.taxonomy.author %}href="{{ base_url }}/author{{ config.system.param_sep }}{{ author }}" itemprop="url" {% endif %}class="author"> <a {% if page.taxonomy.author %}href="{{ base_url }}/author{{ config.system.param_sep }}{{ author }}" itemprop="url" {% endif %}class="author" aria-label="{{ author }}" rel="nofollow">
<span class="name" rel="author">{{ author }}</span> <span class="name" rel="author">{{ author }}</span>
{% if avatar %}<img src="{{ avatar }}" alt="{{ author }}" />{% endif %} {% if avatar %}<img src="{{ avatar }}" alt="{{ author }}" />{% endif %}
</a> </a>
@ -46,7 +50,7 @@
</div> </div>
</header> </header>
{% if image %} {% if image %}
<a class="image featured" href="{{ page.url }}" title="{{ title|raw }}"> <a class="image featured" href="{{ page.url }}" title="{{ title|raw }}" rel="nofollow">
{{ image.cropZoom(1038,437).loading('lazy').attribute('decoding','async').html(title, title)|raw }} {{ image.cropZoom(1038,437).loading('lazy').attribute('decoding','async').html(title, title)|raw }}
</a> </a>
{% endif %} {% endif %}
@ -69,22 +73,22 @@
<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" rel="nofollow">{{'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" rel="nofollow">{{'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> <li>
<a class="button" href="{{ page.prevSibling.url }}"> <a class="button" href="{{ page.prevSibling.url }}" rel="prev">
<i class="fa fa-chevron-left"></i> <i class="fa fa-chevron-left"></i>
{{'FUTURE.BLOG.ITEM.PREV_POST'|t}}</a> {{'FUTURE.BLOG.ITEM.PREV_POST'|t}}</a>
</li> </li>
{% endif %} {% endif %}
{% if not page.isFirst %} {% if not page.isFirst %}
<li> <li>
<a class="button" href="{{ page.nextSibling.url }}">{{'FUTURE.BLOG.ITEM.NEXT_POST'|t}} <a class="button" href="{{ page.nextSibling.url }}" rel="next">{{'FUTURE.BLOG.ITEM.NEXT_POST'|t}}
<i class="fa fa-chevron-right"></i> <i class="fa fa-chevron-right"></i>
</a> </a>
</li> </li>
@ -95,7 +99,7 @@
{% if page.taxonomy.tag %} {% if page.taxonomy.tag %}
<ul class="stats"> <ul class="stats">
{% 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" rel="nofollow">{{ tag }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}