feat: ✨ add gallery page
This commit is contained in:
parent
9354f9f556
commit
add698651e
4 changed files with 86 additions and 22 deletions
|
@ -99,6 +99,7 @@ function render_twig($template, $args = []) {
|
|||
"site_name" => $SITE_CONFIG['opengraph']['site_name'],
|
||||
"title" => $meta['title'] ?? $SITE_CONFIG['opengraph']['site_name'],
|
||||
"url" => $_SERVER['REQUEST_URI'],
|
||||
"type" => "article",
|
||||
"description" => $meta['description']
|
||||
?? $settings['description']
|
||||
?? $SITE_CONFIG['opengraph']['description']
|
||||
|
@ -106,9 +107,10 @@ function render_twig($template, $args = []) {
|
|||
|
||||
if(($meta['type'] ?? '') == 'image') {
|
||||
$args['og']['image'] ??= $meta['media_file'];
|
||||
$args['og']['type'] = "image";
|
||||
}
|
||||
|
||||
$args['og']['image'] ??= $SITE_CONFIG['uri_prefix'] . $args['banner'][0]["src"];
|
||||
$args['og']['image'] ??= $args['banner'][0]["src"];
|
||||
|
||||
$args['banner'] = json_encode($args['banner']);
|
||||
|
||||
|
@ -161,6 +163,25 @@ function try_render_post($SURI) {
|
|||
]);
|
||||
break;
|
||||
|
||||
case 'gallery':
|
||||
if(preg_match('/^(.*[^\/])((?:#.*)?)$/', $SURI, $match)) {
|
||||
header('Location: ' . $match[1] . '/' . $match[2]);
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
$search_query = $post['post_metadata']['search_tags'] ??
|
||||
('+type:image +path:' . $post['post_path'] . '/*');
|
||||
|
||||
$search_result = $adapter->perform_post_search($search_query);
|
||||
|
||||
echo render_twig('post_types/gallery.html', [
|
||||
"post" => $post,
|
||||
"subposts" => $adapter->get_subposts_by_path($SURI),
|
||||
"gallery_images" => $search_result['results']
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
echo render_twig('post_types/image.html', [
|
||||
"post" => $post,
|
||||
|
@ -227,9 +248,6 @@ function generate_website($SURI) {
|
|||
header('Etag: W/"' . $SURI . '/' . strtotime($feed['feed_ts']) . '"');
|
||||
|
||||
echo $feed['feed'];
|
||||
} elseif(!preg_match('/^\s*text\/html/', $_SERVER['HTTP_ACCEPT'])) {
|
||||
header('Location: /raw' . $SURI);
|
||||
exit(0);
|
||||
} elseif(true) {
|
||||
try_render_post($SURI);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue