feature(post rendering): ability to add additional argument contents

This commit is contained in:
David Bailey 2024-11-18 23:00:24 +01:00
parent 626a4bbaf6
commit aabe0c72d5

View file

@ -2,7 +2,6 @@
require_once 'fontawesome.php';
$post = $adapter->get_post($REQUEST_PATH);
function render_root_template($template, $args = []) {
global $twig;
@ -13,8 +12,8 @@ function render_root_template($template, $args = []) {
$args['page'] ??= $SITE_CONFIG['site_defaults'];
$page = $args['page'];
$page['base'] ??= $page['url'];
$page['base'] ??= $page['url'] ?? null;
$args['opengraph'] = [
"site_name" => $page['site_name'] ?? 'Nameless Site',
"title" => $page['title'] ?? 'Titleless',
@ -23,7 +22,7 @@ function render_root_template($template, $args = []) {
];
$args['banners'] = json_encode($page['banners'] ?? []);
$args['age_gate'] = (!isset($_COOKIE['AgeConfirmed']))
&& isset($SITE_CONFIG['age_gate']);
@ -34,9 +33,30 @@ function render_pathed_content_template($template, $args = []) {
render_root_template($template, $args);
}
render_pathed_content_template('post_types/markdown.html', [
'page' => $post
]);
function render_post($post, $args = []) {
$template = $post['template']
?? ($post['markdown'] == '' ? 'directory' : 'vanilla');
if(isset($post['search'])) {
$args['search'] = $adapter->search_posts($post['search']);
}
$args['page'] = $post;
render_pathed_content_template(
'render_templates/' . $template . '.html',
$args);
}
if($REQUEST_PATH == '/upload') {
render_root_template('upload.html');
die();
}
$post = $adapter->get_post($REQUEST_PATH);
render_post($post);
die();
if(!isset($post)) {