deblan.io-murph/templates/page/post/_post.html.twig

225 lines
10 KiB
Twig

{% set full = full is defined and full %}
<div class="col-12">
<div class="body prose-lg">
{% if post.isQuick %}
{{ include('page/post/_quick_post.html.twig') }}
{% else %}
{% if not full %}
<div class="_rounded-2xl _shadow-md _p-5 _pb-0 _bg-box">
<h2 class="h3 no-margin">
<a href="{{ safe_path('blog_menu_post', {post: post.id, slug: post.slug, _domain: _domain}) }}">
{{- post.title -}}
</a>
</h2>
<ul class="flex gap-3 pl-0">
<li class="pl-0 mt-0">
<time datetime="{{ post.publishedAt|date("Y-m-d") }}" title="{{ post.publishedAt|date("r") }}">
{{- 'Le ' ~ post.publishedAt|date("d/m/Y à H\\hi") -}}
</time>
</li>
{% for category in post.categories %}
<li class="pl-0 mt-0">
<a href="{{ safe_path('blog_menu_category', {category: category.id, slug: category.slug, _domain: _domain}) }}">
{{- category.title -}}
</a>
</li>
{% endfor %}
{% for tag in post.tags %}
<li class="pl-0 mt-0">
<a href="{{ safe_path('blog_menu_search', {tag: tag.label, _domain: _domain}) }}">
{{- '#' ~ tag.label -}}
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="body-content">
{% if post.contentFormat == 'html' %}
{{- post.content|murph_url|file_attributes|post -}}
{% elseif post.contentFormat == 'markdown' %}
{{- post.content|murph_url|file_attributes|markdown('post')|lazy_load -}}
{% elseif post.contentFormat == 'editorjs' %}
{{- post.content|murph_url|file_attributes|editorjs_to_html|raw -}}
{% endif %}
</div>
{% endif %}
</div>
</div>
{% if full %}
{% set description = setting('post_author_description') %}
{%- if description and not post.isQuick -%}
<div class="body">
<div class="rounded-2xl shadow-md p-2 md:p-8 flex justify-start bg-box">
{%- set avatar = setting('avatar_image') -%}
{%- if avatar -%}
<p class="mr-8">
<img src="{{ asset(avatar)|imagine_filter('site_avatar') }}" alt="Simon Vieille" title="Simon Vieille" class="rounded-full">
</p>
{%- endif -%}
{{- description|markdown('post') -}}
</div>
</div>
{%- endif -%}
{%- if similarPosts is defined and similarPosts|length > 0 -%}
<div class="body">
<div class="grid grid-flow-row-dens grid-cols-3 gap-5">
{% for item in similarPosts %}
{% set url = safe_path('blog_menu_post', {post: item.id, slug: item.slug, _domain: _domain}) %}
<div class="card shadow-md col-span-3 md:col-span-1 bg-box">
<div class="card">
{%- if item.image -%}
<figure>
<a href="{{ url }}">
{% set image = asset(item.image)|imagine_filter('post_preview_filter') %}
<img src="{{ asset('build/images/px.png') }}" data-src="{{ image }}" alt="{{ item.title }}">
</a>
</figure>
{%- endif -%}
<div class="card-body">
<h3 class="card-title">
<a href="{{- url -}}">
{{- item.title -}}
</a>
</h3>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{%- endif -%}
<div class="col-12">
<div class="reviews">
<hr>
{% set comments = post.comments({
isActive: true,
isFirstLevel: true
}) %}
{% if comments|length %}
{% for comment in comments %}
{{ include('page/post/_comment.html.twig', {comment: comment, level: 1}) }}
{% endfor %}
{% endif %}
{% form_theme form with "form_div_layout.html.twig" %}
<div class="grid" id="form">
<form class="form" method="POST" data-form-bot action="{{ safe_url('blog_tech_form_without_javascript', {page: app.request.uri, _domain: _domain}) }}">
{% if comments|length %}
<hr>
{% endif %}
<div class="h4">Ajouter un commentaire</div>
<div class="grid grid-flow-row-dens grid-cols-2 gap-5">
<div class="col-span-2 md:col-span-1">
{{ form_label(form.author, null, {label_attr: {class: 'label'}}) }}
{{ form_widget(form.author, {attr: {class: 'input input-bordered w-full'}}) }}
{{ form_errors(form.author) }}
</div>
<div class="col-span-2 md:col-span-1">
{{ form_label(form.website, null, {label_attr: {class: 'label'}}) }}
{{ form_widget(form.website, {attr: {class: 'input input-bordered w-full'}}) }}
{{ form_errors(form.website) }}
</div>
<div class="col-span-2">
{{ form_label(form.email, null, {label_attr: {class: 'label'}}) }}
{{ form_widget(form.email, {attr: {class: 'input input-bordered w-full'}}) }}
{{ form_errors(form.email) }}
</div>
<div class="col-span-2">
<div class="label justify-start gap-3">
{{ form_widget(form.follow, {attr: {class: 'checkbox'}}) }}
<label class="label" for="user_comment_follow">{{ form.follow.vars.label }}</label>
</div>
</div>
<div class="col-span-2">
<p class="label">
{{- 'Votre commentaire - Vous pouvez utiliser du markdown ' }}
</p>
{{ form_errors(form.content) }}
{{ form_widget(form.content, {attr: {cols: 30, rows: 10, class: 'textarea textarea-bordered w-full'}}) }}
<div class="hidden alert alert-info mt-5" id="answer-alert">
<div class="w-full flex justify-between">
<div>
{{- 'Vous répondez à un commentaire' -}}
</div>
<div>
<a href="#" class="btn btn-sm" id="cancel-answer">
{{- 'Annuler' -}}
</a>
</div>
</div>
</div>
</div>
<div class="col-span-2">
<div class="flex justify-start gap-3">
{{ form_label(form.captcha, null, {label_attr: {class: 'label'}}) }}
{{ form_widget(form.captcha, {attr: {class: 'input input-bordered'}}) }}
</div>
</div>
<div class="col-span-2">
<label class="label justify-start gap-3" for="rgpd">
<input type="checkbox" id="rgpd" class="checkbox" required>
<span class="label">En validant ce formulaire, vous acceptez que j'utilise votre e-mail pour vous fournir une réponse.</span>
</label>
</div>
<div class="col-span-2">
<input type="submit" class="btn btn-primary mr-2" value="Publier" />
<input type="button" class="btn preview-button" value="Prévisualiser" />
</div>
{{ form_rest(form) }}
</div>
</form>
<div id="preview" class="review-body mt-5 mb-5"></div>
</div>
</div>
</div>
{% if not post.isQuick %}
{%
set ld = {
'@context': 'http://schema.org/',
'@type': 'BlogPosting',
'headline': post.title,
'author': {
'@type': 'Person',
'name': 'Simon Vieille'
},
'publisher': {
'@type': 'Organization',
'name': 'Deblan blog',
'logo': {
'@type': 'imageObject',
'url': asset('build/images/logo.png')
}
},
'datePublished': post.publishedAt|date("c"),
'dateModified': post.updatedAt|date("c"),
'image': post.image ? asset(post.image) : null
}
%}
<script type="application/ld+json">{{- ld|json_encode(128)|replace({'\\/': '/'})|raw -}}</script>
{% endif %}
{% endif %}