mirror of
https://github.com/pmoreno-rodriguez/grav-theme-future2021.git
synced 2025-06-07 20:08:54 +00:00
New recent posts template
This commit is contained in:
parent
bb51b58b2a
commit
9800a44036
1 changed files with 38 additions and 0 deletions
38
templates/partials/sidebar-bits/recentposts.html.twig
Executable file
38
templates/partials/sidebar-bits/recentposts.html.twig
Executable file
|
@ -0,0 +1,38 @@
|
|||
{# Set the number or recent posts will be displayed in sidebar #}
|
||||
{% set recent_enabled = theme_var('recent_posts_enabled')|defined(false) %}
|
||||
{% set recent_number = theme_var('recent_posts_number')|defined(5) %}
|
||||
|
||||
{% if recent_enabled is same as true %}
|
||||
<section>
|
||||
<header class="">
|
||||
<h3>{{ 'FUTURE.SIDEBAR.RECENT_POSTS.HEADLINE'|t }}</h3>
|
||||
</header>
|
||||
<ul class="posts">
|
||||
{% for p in page.find(theme_config.blog_page).children.order('date', 'desc').slice(0, recent_number) %}
|
||||
{% set image = p.media[p.header.primaryImage] ?: p.media.all|filter((v, k) => k != p.header.avatarImage and (v.type == 'image' or v.type == 'vector'))|first %}
|
||||
{% set title = p.title|raw %}
|
||||
<li>
|
||||
<article>
|
||||
<header>
|
||||
<h3>
|
||||
<a href="{{p.url}}">{{ title }}</a>
|
||||
</h3>
|
||||
{# Support for translate and twig extensions plugins #}
|
||||
{% if config.plugins["translate-date"].enabled %}
|
||||
<time class="published" itemprop="datePublished" datetime="{{ p.date|td(null, "Y-m-d") }}">{{ p.date|td(null, "M j, Y") }}</time>
|
||||
{% elseif config.plugins["twig-extensions"].enabled %}
|
||||
<time class="published" itemprop="datePublished" datetime="{{ p.date|localizeddate('medium', 'none', lang) }}">{{ p.date|localizeddate('medium', 'none', lang) }}</time>
|
||||
{% else %}
|
||||
<time class="published" itemprop="datePublished" datetime="{{ p.date|date("Y-m-d") }}">{{ p.date|date("M j, Y") }}</time>
|
||||
{% endif %}
|
||||
</header>
|
||||
<a class="image" aria-label="{{ title }}" href="{{ base_url }}/{{ config.plugins.archives.taxonomy_names.month }}{{ config.system.param_sep }}{{ month|date(config.plugins.archives.taxonomy_values.month)|lower|e('url') }}">
|
||||
{# <a href="{{p.url}}" class="image" aria-label="{{ title }}"> #}
|
||||
{{ image.cropResize(64,64).quality(60).loading('lazy').attribute('decoding','async').html(title,title)|raw }}
|
||||
</a>
|
||||
</article>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
{% endif %}
|
Loading…
Add table
Reference in a new issue