97 lines
4.7 KiB
Twig
97 lines
4.7 KiB
Twig
{% macro news_preview(post, show_category) %}
|
|
{% from 'macros.twig' import container_title, avatar %}
|
|
|
|
<div class="container news__preview">
|
|
<div class="news__preview__header">
|
|
<div class="news__preview__title">
|
|
<h1>{{ post.post.title }}</h1>
|
|
</div>
|
|
<div class="news__preview__attrs">
|
|
<div class="news__preview__attr news__preview__created">
|
|
<div class="news__preview__created__prefix">Posted</div>
|
|
<div class="news__preview__created__time">
|
|
<time datetime="{{ post.post.createdTime|date('c') }}" title="{{ post.post.createdTime|date('r') }}">{{ post.post.createdTime|time_format }}</time>
|
|
</div>
|
|
</div>
|
|
{% if post.user is not null %}
|
|
<div class="news__preview__attr news__preview__author"{% if post.user_colour is defined %} style="--user-colour: {{ post.user_colour }}"{% endif %}>
|
|
<div class="news__preview__author__prefix">by</div>
|
|
<div class="news__preview__author__avatar">
|
|
<a href="{{ url('user-profile', {'user': post.user.id}) }}">{{ avatar(post.user.id, 20, post.user.name) }}</a>
|
|
</div>
|
|
<div class="news__preview__author__name">
|
|
<a href="{{ url('user-profile', {'user': post.user.id}) }}">{{ post.user.name }}</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% if show_category %}
|
|
<div class="news__preview__attr news__preview__category">
|
|
<div class="news__preview__category__prefix">in</div>
|
|
<div class="news__preview__category__name">
|
|
<a href="{{ url('news-category', {'category': post.category.id}) }}">{{ post.category.name }}</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="news__preview__content markdown">
|
|
<div class="news__preview__text">
|
|
{{ post.post.firstParagraph|escape|parse_text(2)|raw }}
|
|
</div>
|
|
<div class="news__preview__links">
|
|
<a href="{{ url('news-post', {'post': post.post.id}) }}" class="news__preview__link">Continue reading</a>
|
|
<a href="{{ url('news-post-comments', {'post': post.post.id}) }}" class="news__preview__link">
|
|
{{ post.comments_count < 1 ? 'No' : post.comments_count|number_format }} comment{{ post.comments_count != 1 ? 's' : '' }}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro news_post(post, category, user, user_colour) %}
|
|
{% from 'macros.twig' import avatar %}
|
|
|
|
<div class="container news__post" style="{% if user_colour is not null %}--accent-colour: {{ user_colour }}{% endif %}">
|
|
<div class="news__post__info">
|
|
<div class="news__post__info__background"></div>
|
|
<div class="news__post__info__content">
|
|
{% if user is not null %}
|
|
<div class="news__post__user">
|
|
<a class="news__post__avatar" href="{{ url('user-profile', {'user': user.id}) }}">
|
|
{{ avatar(user.id, 60, user.name) }}
|
|
</a>
|
|
|
|
<div class="news__post__user__details">
|
|
<a class="news__post__username" href="{{ url('user-profile', {'user': user.id}) }}">{{ user.name }}</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<a class="news__post__category" href="{{ url('news-category', {'category': category.id}) }}">
|
|
{{ category.name }}
|
|
</a>
|
|
|
|
<div class="news__post__date">
|
|
Posted
|
|
<time datetime="{{ post.createdTime|date('c') }}" title="{{ post.createdTime|date('r') }}">
|
|
{{ post.createdTime|time_format }}
|
|
</time>
|
|
</div>
|
|
|
|
{% if post.edited %}
|
|
<div class="news__post__date">
|
|
Updated
|
|
<time datetime="{{ post.updatedTime|date('c') }}" title="{{ post.updatedTime|date('r') }}">
|
|
{{ post.updatedTime|time_format }}
|
|
</time>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="news__post__text markdown">
|
|
<h1>{{ post.title }}</h1>
|
|
{{ post.body|escape|parse_text(2)|raw }}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|