feat: subsites
This commit is contained in:
@@ -30,11 +30,10 @@ export default function Root({ child, user = undefined, ...props }) {
|
||||
// runtime flag `window.__IS_SUBSITE` from the server layout so pages
|
||||
// don't need to pass guards.
|
||||
const isSubsite = typeof document !== 'undefined' && document.documentElement.getAttribute('data-subsite') === 'true';
|
||||
// Helpful runtime debugging: only log when child changes so we don't spam
|
||||
// the console on every render. Use an effect so output is stable.
|
||||
// Log when the active child changes (DEV only)
|
||||
useEffect(() => {
|
||||
try {
|
||||
if (typeof console !== 'undefined' && typeof document !== 'undefined') {
|
||||
if (typeof console !== 'undefined' && typeof document !== 'undefined' && import.meta.env.DEV) {
|
||||
console.debug(`[AppLayout] child=${String(child)}, data-subsite=${document.documentElement.getAttribute('data-subsite')}`);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -58,13 +57,13 @@ export default function Root({ child, user = undefined, ...props }) {
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
if (wantPlayer) {
|
||||
try { console.debug('[AppLayout] dynamic-import: requesting AudioPlayer'); } catch (e) { }
|
||||
if (import.meta.env.DEV) { try { console.debug('[AppLayout] dynamic-import: requesting AudioPlayer'); } catch (e) { } }
|
||||
import('./AudioPlayer.jsx')
|
||||
.then((mod) => {
|
||||
if (!mounted) return;
|
||||
// set the component factory
|
||||
setPlayerComp(() => mod.default ?? null);
|
||||
try { console.debug('[AppLayout] AudioPlayer import succeeded'); } catch (e) { }
|
||||
if (import.meta.env.DEV) { try { console.debug('[AppLayout] AudioPlayer import succeeded'); } catch (e) { } }
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('[AppLayout] AudioPlayer import failed', err);
|
||||
@@ -94,7 +93,7 @@ export default function Root({ child, user = undefined, ...props }) {
|
||||
{child == "LoginPage" && (<LoginPage {...props} loggedIn={loggedIn} />)}
|
||||
{child == "LyricSearch" && (<LyricSearch {...props} client:only="react" />)}
|
||||
{child == "Player" && !isSubsite && PlayerComp && (
|
||||
<Suspense fallback={<div data-testid="player-fallback" className="p-4 text-center">Loading player...</div>}>
|
||||
<Suspense fallback={null}>
|
||||
<PlayerComp client:only="react" user={user} />
|
||||
</Suspense>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user