feat: centralize baseURL and app experience for cloud and self hosted

This commit is contained in:
Rotimi Best
2026-03-11 11:21:41 +01:00
parent a98d6a35fa
commit 74c87fb72a
18 changed files with 81 additions and 100 deletions
+20 -1
View File
@@ -1,4 +1,6 @@
import { writable } from 'svelte/store';
import { derived, writable } from 'svelte/store';
import { PUBLIC_IS_SELFHOSTED } from '$env/static/public';
import { currentOrgPath } from './org';
export const globalStore = writable<{
isDark: boolean;
@@ -11,3 +13,20 @@ export const globalStore = writable<{
orgSiteName: '',
isStudent: undefined
});
/**
* Single source of truth: is this a student experience?
* Cloud: orgSite is always student. Self-hosted: check role.
*/
export const isStudentExperience = derived(globalStore, ($gs) => {
const isCloud = PUBLIC_IS_SELFHOSTED !== 'true';
if (isCloud) return $gs.isOrgSite;
return $gs.isStudent ?? false;
});
/**
* The root path for navigation: '/lms' for students, '/org/{siteName}' for admin/teacher
*/
export const basePath = derived([isStudentExperience, currentOrgPath], ([$isStudent, $orgPath]) =>
$isStudent ? '/lms' : $orgPath
);