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) %}
2018-10-22 19:53:21 +00:00
{% from 'macros.twig' import container_title %}
2018-04-16 00:33:54 +00:00
<div class="container news__preview">
2018-10-22 19:53:21 +00:00
{{ container_title(post.post_title, '/news.php?p=' ~ post.post_id) }}
<div class="news__preview__container">
<div class="news__preview__content">
2018-11-01 21:35:10 +00:00
<div class="news__preview__text markdown">
{{ 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.post_created|date('c') }}" title="{{ post.post_created|date('r') }}">
{{ post.post_created|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 %}