Create a snippet for displaying a card style "post".
This commit is contained in:
34
snippets/collection/post.php
Normal file
34
snippets/collection/post.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="card mb-3<?= r($post->pinned()->isTrue(), " border-light") ?><?= r($post->isDraft(), " text-secondary") ?>">
|
||||
<div class="card-body py-1">
|
||||
<h3 class="card-title mb-0">
|
||||
<a href="<?= $post->url() ?>" class="text-reset text-decoration-none"><?= $post->title() ?></a>
|
||||
<?php if ($post->pinned()->isTrue() || $post->isDraft()) : ?>
|
||||
<div class="float-end">
|
||||
<?= r($post->pinned()->isTrue(), kirbytag("fa", "thumbtack", ["class" => "fa-xs"])) ?>
|
||||
<?= r($post->isDraft(), kirbytag("fa", "pencil-ruler", ["class" => "fa-xs"])) ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</h3>
|
||||
<small class="d-inline-block text-body-secondary pb-2">
|
||||
<?= kirbytag("fa", "calendar-days") ?>
|
||||
<?php if (date_diff(date_create($post->created()->toDate("Y-m-d")), date_create($post->updated()->toDate("Y-m-d")))->format("%a") > 0) : ?>
|
||||
Updated on <span title="Originally posted on <?= $post->created()->toDate('l \t\h\e\ jS \of F Y') ?>"><?= $post->updated()->toDate('l \t\h\e jS \of F Y') ?></span>
|
||||
<?php else : ?>
|
||||
Posted on <?= $post->created()->toDate('l \t\h\e jS \of F Y') ?>
|
||||
<?php endif ?>
|
||||
</small>
|
||||
<hr class="mt-0">
|
||||
|
||||
<?= $post->text()->textExcerpt(600, false) ?>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<small>
|
||||
<div class="float-end">
|
||||
<a href="<?= $post->url() ?>"><?= kirbytag("fa", "angle-double-right") ?> Read The Rest</a>
|
||||
</div>
|
||||
<?php if (($user = kirby()->user()) and $user->role()->isAdmin()) : ?>
|
||||
<a href="<?= $post->panel()->url() ?>" target="_blank"><?= kirbytag("fa", "edit") ?></a>
|
||||
<?php endif ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user