38 lines
927 B
PHP
38 lines
927 B
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Blogs\Blogs;
|
|
use App\Utils\Debug;
|
|
use App\Utils\RenderHtml;
|
|
|
|
class Post {
|
|
|
|
private $title = 'Article title';
|
|
|
|
/**
|
|
* Renders post content
|
|
*
|
|
* @param array $params An array of parameters for the post rendering
|
|
* @return string The rendered content for the post page
|
|
*/
|
|
function index($params = null) {
|
|
ob_start();
|
|
|
|
$posts = new Blogs($params);
|
|
$postInfo = $posts->returnPostInfo($params['slug']);
|
|
$postContent = $posts->findPostBySlug($params['slug']);
|
|
$postContent = RenderHtml::markdownToHtml($postContent);
|
|
$this->title = $postInfo['title'];
|
|
$author = $params['config']['author'];
|
|
|
|
require __DIR__ . '/../../template/post.php';
|
|
$content = ob_get_contents();
|
|
ob_end_clean();
|
|
return $content;
|
|
}
|
|
|
|
function title() {
|
|
return $this->title;
|
|
}
|
|
}
|