/**
* Read a blog post
*
* @param string $year
* @param string $month
* @param string $slug
*
* @route blog/{year}/{month}/{slug}
*/
public function readPost(string $year, string $month, string $slug)
{
$blogPost = $this->blog->getBlogPost($year, $month, $slug);
$post = $this->post(new CommentFilter(), true);
if ($post) {
if ($this->addComment($post, (int) $blogPost['postid'])) {
\Airship\redirect(\Airship\LensFunctions\cabin_url() . 'blog/' . $year . '/' . $month . '/' . $slug . '#comments');
}
}
$mathJAX = \strpos($blogPost['body'], '$$') !== false;
$blogPost['series'] = $this->blog->getPostsSeries((int) $blogPost['postid']);
$args = ['meta' => \json_decode($blogPost['metadata'] ?? '[]', true), 'pageTitle' => $blogPost['title'], 'blogpost' => $blogPost, 'author' => $this->blog->getAuthor($blogPost['author']), 'config' => $this->config(), 'mathjax' => $mathJAX];
if (!empty($blogPost['cache'])) {
$args['cached'] = true;
$this->stasis('blog/read', $args);
} else {
$comments = $this->blog->getCommentTree((int) $blogPost['postid']);
$args['comments'] = $comments;
$this->lens('blog/read', $args);
}
}