'game.html', 'studio' => 'studio.html', 'person' => 'person.html', 'games' => 'index.html', 'studios' => 'studios.html', 'people' => 'people.html', ); $DETAIL_TYPES = array('game', 'studio', 'person'); $type = isset($_GET['t']) ? $_GET['t'] : ''; if (!isset($PAGES[$type])) { http_response_code(404); exit; } // Emits the pre-rendered and exits once it has something to serve. A // detail page falls through when it can't resolve: an unrecognised user // agent, no ?id/?slug to go on, or no such record (already 404'd by then). A // listing page falls through only for an unrecognised user agent or a failed // Supabase fetch — it has no record to look up. if (in_array($type, $DETAIL_TYPES, true)) { slc_meta_shim($type); } else { slc_meta_shim_list($type); } // Fallback: serve the normal static page, so a scraper still gets the site's // default preview rather than an empty body — and a missing record still // answers 404, with something readable attached. header('Content-Type: text/html; charset=utf-8'); // Bot and human hits on the same URL get different bodies (this static page // still carries only the JS-set placeholder tags for a bot, vs. the full // client-rendered page for a human) — Vary stops a shared cache in front of // this host from serving one audience's copy to the other. slc_emit_bot_page() // in meta-shim.php already sets this; this is the same fallback path missing it. header('Vary: User-Agent'); readfile(__DIR__ . '/' . $PAGES[$type]);