--- import { readFileSync } from 'node:fs'; import { join, resolve } from 'node:path'; interface Props { title?: string; description?: string; /** Set true on pages that must remain accessible without auth (login, register). */ public?: boolean; /** Remove the content wrapper so a child can fill the remaining viewport. */ fullscreen?: boolean; } const { title = 'BincioActivity', description = 'Your personal activity stats', public: isPublicPage = false, fullscreen = false } = Astro.props; const editUrl = import.meta.env.PUBLIC_EDIT_URL ?? ''; const wikiUrl = import.meta.env.PUBLIC_WIKI_URL ?? ''; const plannerUrl = import.meta.env.PUBLIC_PLANNER_URL ?? ''; const authUrl = import.meta.env.PUBLIC_AUTH_URL ?? ''; // Edit UI is enabled when PUBLIC_EDIT_URL is set (single-user bincio-edit mode) // OR when PUBLIC_EDIT_ENABLED=true (multi-user VPS mode — API proxied at /api/). const editEnabled = editUrl !== '' || import.meta.env.PUBLIC_EDIT_ENABLED === 'true'; const mobileApp = import.meta.env.PUBLIC_MOBILE_APP === 'true'; const baseUrl = import.meta.env.BASE_URL ?? '/'; // Read root index.json at build time to detect instance configuration. let instancePrivate = false; let singleHandle: string | null = null; // set when there is exactly one shard try { const candidates = [ process.env.BINCIO_DATA_DIR, resolve(process.cwd(), 'public', 'data'), resolve(process.cwd(), '..', 'bincio_data'), ].filter(Boolean) as string[]; const dataDir = candidates.find(d => { try { readFileSync(join(d, 'index.json')); return true; } catch { return false; } }); if (dataDir) { const root = JSON.parse(readFileSync(join(dataDir, 'index.json'), 'utf-8')); instancePrivate = root?.instance?.private === true; const shards: Array<{ handle?: string }> = root?.shards ?? []; const handles = shards.map(s => s.handle).filter(Boolean); if (handles.length === 1 && !instancePrivate) singleHandle = handles[0] as string; } } catch { /* non-fatal */ } --- {title} {instancePrivate && !isPublicPage && ( )} {editEnabled && ( )} {fullscreen ? (
) : (
)} {singleHandle && ( )} {!singleHandle && ( )} {editEnabled && ( )}