feat: rework metadata loading to use site-specific config file
This commit is contained in:
parent
c202b778e0
commit
2ea575f229
3 changed files with 21 additions and 16 deletions
|
@ -78,6 +78,7 @@ $twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
|
|||
function render_twig($template, $args = []) {
|
||||
global $twig;
|
||||
global $FONT_AWESOME_ARRAY;
|
||||
global $SITE_CONFIG;
|
||||
|
||||
$args['fa'] = $FONT_AWESOME_ARRAY;
|
||||
|
||||
|
@ -85,27 +86,27 @@ function render_twig($template, $args = []) {
|
|||
$settings = $post['settings'] ?? [];
|
||||
$meta = $post['post_metadata'] ?? [];
|
||||
|
||||
$args['banner'] ??= $settings['banners'] ?? [
|
||||
["src"=> "/static/banner/0.png"],
|
||||
["src" => "/static/banner/1.png"]
|
||||
];
|
||||
$args['banner'] ??= $settings['banners'] ?? $SITE_CONFIG['banners'];
|
||||
|
||||
$args['og'] = array_merge([
|
||||
"title" => $meta['title'] ?? "Dergennibble",
|
||||
"site_name" => $SITE_CONFIG['opengraph']['site_name'],
|
||||
"title" => $meta['title'] ?? $SITE_CONFIG['opengraph']['site_name'],
|
||||
"url" => $_SERVER['REQUEST_URI'],
|
||||
"description" => $meta['description']
|
||||
?? $settings['description']
|
||||
?? "The softest spot to find dragons on"
|
||||
?? $SITE_CONFIG['opengraph']['description']
|
||||
], $args['og'] ?? []);
|
||||
|
||||
if(($meta['type'] ?? '') == 'image') {
|
||||
$args['og']['image'] ??= "https://lucidragons.de" . $post['post_file_dir'];
|
||||
$args['og']['image'] ??= $meta['media_file'];
|
||||
}
|
||||
|
||||
$args['og']['image'] ??= 'https://lucidragons.de' . $args['banner'][0]["src"];
|
||||
$args['og']['image'] ??= $SITE_CONFIG['uri_prefix'] . $args['banner'][0]["src"];
|
||||
|
||||
$args['banner'] = json_encode($args['banner']);
|
||||
|
||||
$args['site_config'] = $SITE_CONFIG;
|
||||
|
||||
echo $twig->render($template, $args);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue