<?php snippet('header') ?>

	<main class="content blog">
		<div class="mainwrapper">

			<?php if(isset($tag)): ?>
					<h2 class="tagged" >Posts tagged with #<?php echo $tag;?>.</h2></br>
			<?php endif ?>			

			<!-- sidebar with tagcloud -->
			<aside class="tagcloud" >
				You can find the Feed <a href="<?php echo url('notes/feed')?>" class="feed">here</a>.<br />
				Tags:
				<ul class="tags">
				<?php foreach($tags as $tag): ?>
					<li>
						<a href="<?php echo $page->url() . '/tag:' . $tag ?>">
							<?php echo html($tag) ?>
						</a>
					</li>
				<?php endforeach ?>
				</ul>
			</aside>
			
			<!-- articles -->
			<section class="articles" >
				<?php foreach($articles as $article): ?>
					<article>
						<h1><a href="<?php echo $article->url() ?>"><?php echo $article->title()->html() ?></a></h1>
							<?php echo split_words($article->text()->kirbytext(), $article->url()) ?><br/>
					</article>
				<?php endforeach ?>
			</section>

			<!-- pagination -->
			<?php if($pagination->hasPrevPage() || $pagination->hasNextPage()): ?>
			<nav class="pagination">
				<?php if($pagination->hasPrevPage()): ?>
					<a href="<?php echo $pagination->prevPageUrl() ?>" class="prev" >&larrtl; newer posts</a>
				<?php endif ?>
                <?php echo($pagination->page() . " &frasl; " . $pagination->lastPage())?>
				<?php if($pagination->hasNextPage()): ?>
					<a href="<?php echo $pagination->nextPageUrl() ?>" class="next" >older posts &rarrtl;</a>
				<?php endif ?>
			</nav>
            <?php endif ?>
		</div>
	</main>

<?php snippet('footer') ?>