feature(posts): Added template parameter

This commit is contained in:
David Bailey 2024-11-19 08:59:58 +01:00
parent aabe0c72d5
commit f9cfb81079

View file

@ -49,6 +49,7 @@ class Post implements ArrayAccess {
$icon_mapping = [
'' => 'question',
'text/markdown' => 'markdown',
'markdown' => 'markdown',
'blog' => 'markdown',
'blog_list' => 'rectangle-list',
'directory' => 'folder',
@ -59,6 +60,14 @@ class Post implements ArrayAccess {
return $icon_mapping[$type] ?? 'unknown';
}
public static function _deduce_template($type) {
$template_mapping = [
'directory' => 'directory'
];
return $template_mapping[$type] ?? 'vanilla';
}
function __construct($post_handler, $post_data, $site_defaults) {
$this->handler = $post_handler;
@ -90,6 +99,7 @@ class Post implements ArrayAccess {
$data['type'] ??= self::_deduce_type($post_data['path']);
$data['icon'] ??= self::_deduce_icon($data['type']);
$data['template'] ??= self::_deduce_template($data['type']);
if(isset($sql_meta['media_url'])) {
$data['thumb_url'] ??= $data['media_url'];