KT-personal-website/app/Controllers/Post.php

39 lines
927 B
PHP
Raw Normal View History

2024-10-22 12:26:08 +02:00
<?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;
}
}