2025-08-05 17:40:31 +01:00
|
|
|
import { getSupabase, supabase } from '$lib/utils/functions/supabase';
|
2025-05-03 14:46:01 +01:00
|
|
|
|
2025-12-22 02:36:48 +01:00
|
|
|
import type { AccountOrg } from '$features/app/types';
|
2025-08-05 17:40:31 +01:00
|
|
|
import type { MetaTagsProps } from 'svelte-meta-tags';
|
2025-10-11 13:27:50 +01:00
|
|
|
import { PUBLIC_IS_SELFHOSTED } from '$env/static/public';
|
2024-12-28 23:11:55 +01:00
|
|
|
import { dev } from '$app/environment';
|
2024-10-09 15:00:30 +01:00
|
|
|
import { env } from '$env/dynamic/private';
|
2025-12-22 02:36:48 +01:00
|
|
|
import { getOrgSiteInfo } from '$features/app/layout-setup';
|
2024-12-28 23:11:55 +01:00
|
|
|
import { redirect } from '@sveltejs/kit';
|
2023-08-21 10:10:11 +01:00
|
|
|
|
|
|
|
|
if (!supabase) {
|
|
|
|
|
getSupabase();
|
|
|
|
|
}
|
2023-08-14 06:22:03 +01:00
|
|
|
|
2025-09-07 10:24:34 +01:00
|
|
|
export const ssr = PUBLIC_IS_SELFHOSTED === 'true' ? false : true;
|
2025-05-03 14:46:01 +01:00
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
const APP_SUBDOMAINS = env.PRIVATE_APP_SUBDOMAINS?.split(',') || [];
|
|
|
|
|
|
2023-10-29 12:07:34 +00:00
|
|
|
interface LoadOutput {
|
|
|
|
|
orgSiteName: string;
|
|
|
|
|
isOrgSite: boolean;
|
|
|
|
|
skipAuth: boolean;
|
2025-12-02 09:54:38 +01:00
|
|
|
org: AccountOrg | null;
|
2024-08-01 14:04:50 +01:00
|
|
|
baseMetaTags: MetaTagsProps;
|
2024-12-28 23:11:55 +01:00
|
|
|
serverLang: string;
|
2025-11-24 01:00:50 +01:00
|
|
|
locals: App.Locals;
|
2023-10-29 12:07:34 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
export const load = async ({ url, cookies, request, locals }): Promise<LoadOutput> => {
|
|
|
|
|
const debugPlay = cookies.get('debugPlay');
|
|
|
|
|
|
|
|
|
|
const orgSiteInfo = await getOrgSiteInfo(url, cookies);
|
2025-01-06 03:36:00 +01:00
|
|
|
|
2023-12-03 16:29:27 +03:00
|
|
|
const response: LoadOutput = {
|
2025-11-24 01:00:50 +01:00
|
|
|
orgSiteName: orgSiteInfo.orgSiteName,
|
|
|
|
|
isOrgSite: orgSiteInfo.isOrgSite,
|
|
|
|
|
skipAuth: orgSiteInfo.subdomain === 'play' || debugPlay === 'true',
|
|
|
|
|
org: orgSiteInfo.org,
|
2024-12-28 23:11:55 +01:00
|
|
|
baseMetaTags: getBaseMetaTags(url),
|
2025-11-24 01:00:50 +01:00
|
|
|
serverLang: request.headers?.get('accept-language') || '',
|
|
|
|
|
locals
|
2023-08-14 06:22:03 +01:00
|
|
|
};
|
|
|
|
|
|
2025-09-07 10:24:34 +01:00
|
|
|
console.log('PUBLIC_IS_SELFHOSTED', PUBLIC_IS_SELFHOSTED);
|
2025-01-06 03:36:00 +01:00
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
// If it isn't a registered dashboard domain and also not a valid sub domain.
|
|
|
|
|
if (!APP_SUBDOMAINS.includes(orgSiteInfo.subdomain) && !dev && !orgSiteInfo.isOrgSite) {
|
2025-11-01 15:49:29 +01:00
|
|
|
redirect(307, 'https://app.classroomio.com');
|
2023-08-14 06:22:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
};
|
2024-04-19 05:45:48 +01:00
|
|
|
|
2024-08-01 14:04:50 +01:00
|
|
|
function getBaseMetaTags(url: URL) {
|
|
|
|
|
return Object.freeze({
|
2024-10-07 01:36:07 +01:00
|
|
|
title: 'ClassroomIO | The Open Source Learning Management System for Companies',
|
2024-08-01 14:04:50 +01:00
|
|
|
description:
|
2024-10-07 01:36:07 +01:00
|
|
|
'A flexible, user-friendly platform for creating, managing, and delivering courses for companies and training organisations',
|
2024-08-01 14:04:50 +01:00
|
|
|
canonical: new URL(url.pathname, url.origin).href,
|
|
|
|
|
openGraph: {
|
|
|
|
|
type: 'website',
|
|
|
|
|
url: new URL(url.pathname, url.origin).href,
|
|
|
|
|
locale: 'en_IE',
|
2024-10-07 01:36:07 +01:00
|
|
|
title: 'ClassroomIO | The Open Source Learning Management System for Companies',
|
2024-08-01 14:04:50 +01:00
|
|
|
description:
|
2024-10-07 01:36:07 +01:00
|
|
|
'A flexible, user-friendly platform for creating, managing, and delivering courses for companies and training organisations',
|
2024-08-01 14:04:50 +01:00
|
|
|
siteName: 'ClassroomIO',
|
|
|
|
|
images: [
|
|
|
|
|
{
|
2024-09-05 15:51:05 +01:00
|
|
|
url: 'https://brand.cdn.clsrio.com/og/classroomio-og.png',
|
2024-08-01 14:04:50 +01:00
|
|
|
alt: 'ClassroomIO OG Image',
|
|
|
|
|
width: 1920,
|
|
|
|
|
height: 1080,
|
2024-09-05 15:51:05 +01:00
|
|
|
secureUrl: 'https://brand.cdn.clsrio.com/og/classroomio-og.png',
|
2024-08-01 14:04:50 +01:00
|
|
|
type: 'image/jpeg'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
twitter: {
|
|
|
|
|
handle: '@classroomio',
|
|
|
|
|
site: '@classroomio',
|
2024-08-25 21:35:59 +01:00
|
|
|
cardType: 'summary_large_image' as const,
|
2024-10-07 01:36:07 +01:00
|
|
|
title: 'ClassroomIO | The Open Source Learning Management System for Companies',
|
2024-08-01 14:04:50 +01:00
|
|
|
description:
|
2024-10-07 01:36:07 +01:00
|
|
|
'A flexible, user-friendly platform for creating, managing, and delivering courses for companies and training organisations',
|
2024-09-05 15:51:05 +01:00
|
|
|
image: 'https://brand.cdn.clsrio.com/og/classroomio-og.png',
|
2024-08-01 14:04:50 +01:00
|
|
|
imageAlt: 'ClassroomIO OG Image'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|