blog/themes/cmd/layout/includes/postlist.njk
2022-04-30 00:34:46 +08:00

43 lines
1.5 KiB
Text

{%from 'includes/tags.njk' import PostTags with context%}
{% macro PostList(posts) %}
<ul class="collection">
{% for post in posts %}
<li class="collection-item no-padding">
<div class="card z-depth-0 card-small-margin">
{% if post.photos and post.photos.length > 0 %}
<a href="{{ url_for(post.path) }}">
<div class="card-image">
<img class="responsive-img" src="{{ post.photos[0] }}"/>
<span class="card-title">{{ post.title }}</span>
</div>
</a>
{% if (post.tags.length > 0) or post.excerpt != "" %}
<div class="card-content">
{{ PostTags(post) }}
{% if post.excerpt != "" %}
<p class="entry">{{ post.excerpt }}</p>
{% endif %}
</div>
{% endif %}
{% else %}
<div class="card-content">
<a href="{{ post.link if post.link else url_for(post.path) }}" {% if post.link %} target="_blank" {% endif %}>
<span class="card-title">
{% if (post.title != '' and post.title !== null and post.title !== undefined) %}
{{ post.title }}
{% else %}
{{ post.path }}
{% endif %}
</span>
</a>
<div class="entry">{{ post.excerpt }}</div>
{{ PostTags(post) }}
</div>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
{% endmacro %}