misuzu/templates/news/macros.twig

37 lines
1.7 KiB
Twig
Raw Normal View History

2018-04-16 00:33:54 +00:00
{% macro news_preview(post) %}
<div class="container news__preview">
<a href="/news.php?p={{ post.post_id }}" class="container__title container__title--link">
2018-04-16 00:33:54 +00:00
{{ post.post_title }}
</a>
<div class="news__preview__container">
<div class="news__preview__content">
<div class="news__preview__text">
{{ post.post_text|first_paragraph|parse_text(constant('MSZ_PARSER_MARKDOWN'))|raw }}
</div>
2018-07-15 02:15:12 +00:00
{% if post.user_id is not null %}
<a class="news__preview__user" href="/profile.php?u={{ post.user_id }}">
<div class="avatar news__preview__user__avatar" style="background-image:url('/profile.php?u={{ post.user_id }}&amp;m=avatar')"></div>
2018-09-23 14:42:15 +00:00
<div class="news__preview__user__name" style="{{ post.user_colour|html_colour }}">
2018-07-15 02:15:12 +00:00
{{ post.username }}
</div>
</a>
{% endif %}
</div>
<div class="news__preview__info">
<a href="/news.php?p={{ post.post_id }}" class="news__preview__link">
<time class="news__preview__date" datetime="{{ post.created_at|date('c') }}" title="{{ post.created_at|date('r') }}">
{{ post.created_at|time_diff }}
</time>
</a>
<a href="/news.php?p={{ post.post_id }}#comments" class="news__preview__link">
{{ post.post_comments < 1 ? 'No' : post.post_comments|number_format }} comment{{ post.post_comments != 1 ? 's' : '' }}
</a>
2018-04-16 00:33:54 +00:00
</div>
</div>
</div>
{% endmacro %}