misuzu/templates/news/macros.twig

95 lines
4.2 KiB
Twig
Raw Normal View History

2022-09-13 13:14:49 +00:00
{% macro news_preview(post) %}
{% from 'macros.twig' import container_title, avatar %}
<div class="container news__preview" style="{% if post.user is not null %}--user-colour: {{ post.user.colour }}{% endif %}">
<div class="news__preview__info">
<div class="news__preview__info__background"></div>
<div class="news__preview__info__content">
{% if post.user.id is not null %}
<div class="news__preview__user">
<a class="news__preview__avatar" href="{{ url('user-profile', {'user': post.user.id}) }}">
{{ avatar(post.user.id, 60, post.user.username) }}
</a>
<div class="news__preview__user__details">
<a class="news__preview__username" href="{{ url('user-profile', {'user': post.user.id}) }}">{{ post.user.username }}</a>
</div>
</div>
{% endif %}
<a class="news__preview__category" href="{{ url('news-category', {'category': post.category.id}) }}">
{{ post.category.name }}
</a>
<div class="news__preview__date">
Posted
2023-07-15 17:02:46 +00:00
<time datetime="{{ post.post.createdTime|date('c') }}" title="{{ post.post.createdTime|date('r') }}">
{{ post.post.createdTime|time_diff }}
2022-09-13 13:14:49 +00:00
</time>
</div>
</div>
</div>
<div class="news__preview__content markdown">
2023-07-15 17:02:46 +00:00
<h1>{{ post.post.title }}</h1>
2022-09-13 13:14:49 +00:00
<div class="news__preview__text">
2023-07-15 17:02:46 +00:00
{{ post.post.firstParagraph|parse_text(2)|raw }}
2022-09-13 13:14:49 +00:00
</div>
<div class="news__preview__links">
2023-07-15 17:02:46 +00:00
<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' : '' }}
2022-09-13 13:14:49 +00:00
</a>
</div>
</div>
</div>
{% endmacro %}
2023-07-15 17:02:46 +00:00
{% macro news_post(post, category, user) %}
2022-09-13 13:14:49 +00:00
{% from 'macros.twig' import avatar %}
2023-07-15 17:02:46 +00:00
<div class="container news__post" style="{% if user is not null %}--accent-colour: {{ user.colour }}{% endif %}">
2022-09-13 13:14:49 +00:00
<div class="news__post__info">
<div class="news__post__info__background"></div>
<div class="news__post__info__content">
2023-07-15 17:02:46 +00:00
{% if user is not null %}
2022-09-13 13:14:49 +00:00
<div class="news__post__user">
2023-07-15 17:02:46 +00:00
<a class="news__post__avatar" href="{{ url('user-profile', {'user': user.id}) }}">
{{ avatar(user.id, 60, user.username) }}
2022-09-13 13:14:49 +00:00
</a>
<div class="news__post__user__details">
2023-07-15 17:02:46 +00:00
<a class="news__post__username" href="{{ url('user-profile', {'user': user.id}) }}">{{ user.username }}</a>
2022-09-13 13:14:49 +00:00
</div>
</div>
{% endif %}
2023-07-15 17:02:46 +00:00
<a class="news__post__category" href="{{ url('news-category', {'category': category.id}) }}">
{{ category.name }}
2022-09-13 13:14:49 +00:00
</a>
<div class="news__post__date">
Posted
<time datetime="{{ post.createdTime|date('c') }}" title="{{ post.createdTime|date('r') }}">
{{ post.createdTime|time_diff }}
</time>
</div>
{% if post.isEdited %}
<div class="news__post__date">
Updated
<time datetime="{{ post.updatedTime|date('c') }}" title="{{ post.updatedTime|date('r') }}">
{{ post.updatedTime|time_diff }}
</time>
</div>
{% endif %}
</div>
</div>
<div class="news__post__text markdown">
<h1>{{ post.title }}</h1>
2023-07-15 17:02:46 +00:00
{{ post.body|parse_text(2)|raw }}
2022-09-13 13:14:49 +00:00
</div>
</div>
{% endmacro %}