From 15dc5924ca41304982e5f5d51332b9849f51785d Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sun, 6 Aug 2023 17:29:06 +0100 Subject: [PATCH] Add redirect to layout's load --- src/lib/components/Navigation/index.svelte | 5 +---- src/routes/+layout.js | 9 +++++++++ src/routes/hooks.server.ts | 11 ----------- 3 files changed, 10 insertions(+), 15 deletions(-) create mode 100644 src/routes/+layout.js delete mode 100644 src/routes/hooks.server.ts diff --git a/src/lib/components/Navigation/index.svelte b/src/lib/components/Navigation/index.svelte index 81d5b7bc..090a42ff 100644 --- a/src/lib/components/Navigation/index.svelte +++ b/src/lib/components/Navigation/index.svelte @@ -65,10 +65,7 @@ label="Login" variant={VARIANTS.OUTLINED} className="mx-2" - onClick={() => { - console.log('clicked login'); - goto('/login' + redirect); - }} + onClick={() => goto('/login' + redirect)} /> { + console.log('url', url.hostname); + + if (url.hostname === 'classroomio.com' || url.hostname === 'classroomio.netlify.app') { + throw redirect(301, 'https://about.classroomio.com'); + } +}; diff --git a/src/routes/hooks.server.ts b/src/routes/hooks.server.ts deleted file mode 100644 index e91d4983..00000000 --- a/src/routes/hooks.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Handle } from '@sveltejs/kit'; -import { redirect } from '@sveltejs/kit'; - -export const handle = (async ({ event, resolve }) => { - if (event.url.host === 'classroomio.com') { - throw redirect(307, 'https://about.classroomio.com'); - } - - const response = await resolve(event); - return response; -}) satisfies Handle;