[SITE] add template, blueprint, css for the blog
This commit is contained in:
parent
64cb550e9f
commit
2f2fa568ef
14 changed files with 466 additions and 9 deletions
83
site/templates/blog.php
Normal file
83
site/templates/blog.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
// -------------------------------------------
|
||||
// kirby template FOR jannikbeyerstedt.de
|
||||
|
||||
// copyright: Jannik Beyerstedt | https://jannikbeyerstedt.de
|
||||
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
|
||||
// -------------------------------------------
|
||||
|
||||
$base_url = $site->find('blog')->url();
|
||||
function tags($base_url, $article) {
|
||||
$tags = explode(',',(string)$article->tags());
|
||||
|
||||
if (!empty($tags[0])) {
|
||||
$return_val = '<span class="tags">';
|
||||
foreach ($tags as $tag) {
|
||||
$url = $base_url.'/tag:'.$tag;
|
||||
$return_val .= '<a href="'.$url.'">' . $tag . '</a> ';
|
||||
}
|
||||
$return_val .= '</span>';
|
||||
return $return_val;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$articles = $page->children()->visible()->flip();
|
||||
|
||||
$title = $page->title()->html();
|
||||
|
||||
if($tag = param('tag')) {
|
||||
$articles = $articles->filterBy('tags', $tag, ',');
|
||||
$title .= ' - '.$tag;
|
||||
}
|
||||
|
||||
$articles = $articles->paginate(6);
|
||||
$pagination = $articles->pagination();
|
||||
|
||||
snippet('blog-htmlhead');
|
||||
snippet('base/cont-header');
|
||||
?>
|
||||
|
||||
<main class="section blog">
|
||||
<div class="container">
|
||||
|
||||
<h1><a href="<?php echo $base_url ?>"><?php echo $title ?></a></h1>
|
||||
<?php echo $page->text()->kirbytext(); ?>
|
||||
|
||||
<?php if($pagination->hasPages() && $pagination->page() != 1): ?>
|
||||
<nav class="pagination">
|
||||
<?php if($pagination->hasNextPage()): ?>
|
||||
<a class="button older" href="<?php echo $pagination->nextPageURL() ?>">‹ älter</a>
|
||||
<?php endif ?>
|
||||
<span class="num-pages">Seite <?php echo $pagination->page() ?> von <?php echo $pagination->pages() ?></span>
|
||||
<?php if($pagination->hasPrevPage()): ?>
|
||||
<a class="button newer" href="<?php echo $pagination->prevPageURL() ?>">neuer ›</a>
|
||||
<?php endif ?>
|
||||
</nav>
|
||||
<?php endif ?>
|
||||
|
||||
|
||||
<?php foreach($articles as $a) {
|
||||
echo snippet('blogexcerpt',["article"=>$a,"length"=>200,"base_url"=>$base_url]);
|
||||
}?>
|
||||
|
||||
|
||||
<?php if($pagination->hasPages()): ?>
|
||||
<nav class="pagination">
|
||||
<?php if($pagination->hasNextPage()): ?>
|
||||
<a class="button older" href="<?php echo $pagination->nextPageURL() ?>">‹ älter</a>
|
||||
<?php endif ?>
|
||||
<span class="num-pages">Seite <?php echo $pagination->page() ?> von <?php echo $pagination->pages() ?></span>
|
||||
<?php if($pagination->hasPrevPage()): ?>
|
||||
<a class="button newer" href="<?php echo $pagination->prevPageURL() ?>">neuer ›</a>
|
||||
<?php endif ?>
|
||||
</nav>
|
||||
<?php endif ?>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php snippet('base/cont-footer') ?>
|
||||
<?php snippet('base/html-end', ["bs_util"=>1,
|
||||
"bs_collapse"=>1]) ?>
|
Loading…
Add table
Add a link
Reference in a new issue