From ffb3bdc407953ebbc1bdb4bfca0010ecb6ab9e7a Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:04:19 +0000 Subject: [PATCH 01/10] fix discord banner --- src/lib/layouts/Main.svelte | 18 ++++++++++-------- src/routes/+layout.server.ts | 6 ++++++ src/routes/api/banner/+server.ts | 11 +++++++++++ src/routes/api/banner/constants.ts | 1 + 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 src/routes/api/banner/+server.ts create mode 100644 src/routes/api/banner/constants.ts diff --git a/src/lib/layouts/Main.svelte b/src/lib/layouts/Main.svelte index 2ee1dac49e..c24bb0b35e 100644 --- a/src/lib/layouts/Main.svelte +++ b/src/lib/layouts/Main.svelte @@ -11,13 +11,13 @@
@@ -167,7 +169,7 @@ class:is-transparent={browser} class:is-hidden={$isHeaderHidden} > - {#if $showTopBanner} + {#if showTopBanner}
@@ -179,7 +181,7 @@ diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 189f71e2e1..8a12a50c85 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -1 +1,7 @@ +import { BANNER_KEY } from './api/banner/constants.js'; + export const prerender = true; + +export const load = async ({ cookies }) => { + return { showBanner: cookies.get(BANNER_KEY) !== 'true' }; +}; diff --git a/src/routes/api/banner/+server.ts b/src/routes/api/banner/+server.ts new file mode 100644 index 0000000000..0dc72f3114 --- /dev/null +++ b/src/routes/api/banner/+server.ts @@ -0,0 +1,11 @@ +import { BANNER_KEY } from './constants.js'; + +export const POST = ({ cookies }) => { + cookies.set(BANNER_KEY, 'true', { + path: '/' + }); + + return new Response(null, { + status: 200 + }); +}; diff --git a/src/routes/api/banner/constants.ts b/src/routes/api/banner/constants.ts new file mode 100644 index 0000000000..41bf2f8e73 --- /dev/null +++ b/src/routes/api/banner/constants.ts @@ -0,0 +1 @@ +export const BANNER_KEY = 'discord-banner-00'; // Change key to force banner to show again From 8d90c6fbc9e5b1db4a1f224f6da663e47136cad9 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:09:52 +0000 Subject: [PATCH 02/10] fix deployment --- src/routes/api/banner/+server.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/routes/api/banner/+server.ts b/src/routes/api/banner/+server.ts index 0dc72f3114..f6e08c9553 100644 --- a/src/routes/api/banner/+server.ts +++ b/src/routes/api/banner/+server.ts @@ -1,5 +1,9 @@ import { BANNER_KEY } from './constants.js'; +const isVercel = process.env.VERCEL === '1'; + +export const prerender = isVercel; + export const POST = ({ cookies }) => { cookies.set(BANNER_KEY, 'true', { path: '/' From 3ff101d7ac32dd5311fbe2aebd4879513f2c4099 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:31:56 +0000 Subject: [PATCH 03/10] fix navbar FOUC --- src/app.html | 2 ++ src/lib/layouts/Main.svelte | 3 +-- src/scss/7-components/_main-header.scss | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app.html b/src/app.html index 8950633bb9..541e0bd8dc 100644 --- a/src/app.html +++ b/src/app.html @@ -35,6 +35,8 @@ } } } + + document.body.dataset.jsEnabled = '';
%sveltekit.body%
diff --git a/src/lib/layouts/Main.svelte b/src/lib/layouts/Main.svelte index c24bb0b35e..163672e7ba 100644 --- a/src/lib/layouts/Main.svelte +++ b/src/lib/layouts/Main.svelte @@ -165,8 +165,7 @@
{#if showTopBanner} diff --git a/src/scss/7-components/_main-header.scss b/src/scss/7-components/_main-header.scss index 4cd98aab1a..dbca396d91 100644 --- a/src/scss/7-components/_main-header.scss +++ b/src/scss/7-components/_main-header.scss @@ -44,7 +44,11 @@ &-link { color:hsl(var(--color-neutral-0) / 0.64); } } - &.is-transparent { background-color:transparent; -webkit-backdrop-filter:blur(pxToRem(10)); backdrop-filter:blur(pxToRem(10)); } + &.is-transparent { + [data-js-enabled] & { + background-color: transparent; -webkit-backdrop-filter:blur(pxToRem(10)); backdrop-filter:blur(pxToRem(10)); + } + } #{$theme-dark} &, &#{$theme-dark} { From 34f8b90e026893242340ec29fb38569c5ffa2b87 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:38:26 +0000 Subject: [PATCH 04/10] fix ref FOUC --- src/routes/docs/references/+layout.svelte | 16 ++++------------ .../[platform]/[service]/+layout.svelte | 16 ---------------- 2 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 src/routes/docs/references/[version]/[platform]/[service]/+layout.svelte diff --git a/src/routes/docs/references/+layout.svelte b/src/routes/docs/references/+layout.svelte index 965ffd6917..d58cdbdb97 100644 --- a/src/routes/docs/references/+layout.svelte +++ b/src/routes/docs/references/+layout.svelte @@ -1,18 +1,10 @@ - - - - + + diff --git a/src/routes/docs/references/[version]/[platform]/[service]/+layout.svelte b/src/routes/docs/references/[version]/[platform]/[service]/+layout.svelte deleted file mode 100644 index 62dfb05f9a..0000000000 --- a/src/routes/docs/references/[version]/[platform]/[service]/+layout.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - - From 86dc29f16d8c149abf32a847c90f6cff92a239fd Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:54:36 +0000 Subject: [PATCH 05/10] fix deploy --- svelte.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svelte.config.js b/svelte.config.js index 61e453216d..580b3bc51f 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -13,7 +13,7 @@ function absoulute(path) { const isVercel = process.env.VERCEL === '1'; -const adapter = isVercel ? staticAdapter() : nodeAdapter(); +const adapter = isVercel ? staticAdapter({ strict: false }) : nodeAdapter(); /** @type {import('@sveltejs/kit').Config}*/ const config = { From 6745f8f6848c448f450ad8759daafd77016f4ac1 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:54:36 +0000 Subject: [PATCH 06/10] fix deploy --- src/routes/api/banner/+server.ts | 4 ---- svelte.config.js | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/routes/api/banner/+server.ts b/src/routes/api/banner/+server.ts index f6e08c9553..0dc72f3114 100644 --- a/src/routes/api/banner/+server.ts +++ b/src/routes/api/banner/+server.ts @@ -1,9 +1,5 @@ import { BANNER_KEY } from './constants.js'; -const isVercel = process.env.VERCEL === '1'; - -export const prerender = isVercel; - export const POST = ({ cookies }) => { cookies.set(BANNER_KEY, 'true', { path: '/' diff --git a/svelte.config.js b/svelte.config.js index 61e453216d..580b3bc51f 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -13,7 +13,7 @@ function absoulute(path) { const isVercel = process.env.VERCEL === '1'; -const adapter = isVercel ? staticAdapter() : nodeAdapter(); +const adapter = isVercel ? staticAdapter({ strict: false }) : nodeAdapter(); /** @type {import('@sveltejs/kit').Config}*/ const config = { From d32f437a20704a37a276006a054157ce8e74ceb3 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:23:32 +0000 Subject: [PATCH 07/10] change outdir --- svelte.config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/svelte.config.js b/svelte.config.js index 580b3bc51f..ba6af2d5fb 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,9 +11,10 @@ function absoulute(path) { return join(dirname(fileURLToPath(import.meta.url)), path); } -const isVercel = process.env.VERCEL === '1'; +// const isVercel = process.env.VERCEL === '1'; +const isVercel = true; -const adapter = isVercel ? staticAdapter({ strict: false }) : nodeAdapter(); +const adapter = isVercel ? staticAdapter({ strict: false, pages: 'public' }) : nodeAdapter(); /** @type {import('@sveltejs/kit').Config}*/ const config = { From 7064427e8f6f5a71d8405346dbf8e1288d8e9fa5 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:29:52 +0000 Subject: [PATCH 08/10] refactor banner solution --- src/app.html | 9 +++++ src/hooks/server.ts | 33 ++++++++++++------ src/lib/constants.ts | 1 + src/lib/layouts/Main.svelte | 47 ++++++++++++-------------- src/routes/+layout.server.ts | 7 ---- src/routes/api/banner/+server.ts | 11 ------ src/routes/api/banner/constants.ts | 1 - src/routes/api/blog/+server.ts | 28 --------------- src/scss/7-components/_top-banner.scss | 4 +++ svelte.config.js | 3 +- 10 files changed, 58 insertions(+), 86 deletions(-) create mode 100644 src/lib/constants.ts delete mode 100644 src/routes/+layout.server.ts delete mode 100644 src/routes/api/banner/+server.ts delete mode 100644 src/routes/api/banner/constants.ts delete mode 100644 src/routes/api/blog/+server.ts diff --git a/src/app.html b/src/app.html index 541e0bd8dc..86bd6cd574 100644 --- a/src/app.html +++ b/src/app.html @@ -19,6 +19,7 @@
%sveltekit.body%
diff --git a/src/hooks/server.ts b/src/hooks/server.ts index 986493c405..4543ef0ab8 100644 --- a/src/hooks/server.ts +++ b/src/hooks/server.ts @@ -1,18 +1,29 @@ import type { Handle } from '@sveltejs/kit'; import redirects from './redirects.json'; +import { sequence } from '@sveltejs/kit/hooks'; +import { BANNER_KEY } from '$lib/constants'; const redirectMap = new Map(redirects.map(({ link, redirect }) => [link, redirect])); -export const handle: Handle = async ({ event, resolve }) => { - const currentPath = event.url.pathname; - if (redirectMap.has(currentPath)) { - return new Response(null, { - status: 308, - headers: { - location: redirectMap.get(currentPath) ?? '' - } - }); - } +const redirecter: Handle = async ({ event, resolve }) => { + const currentPath = event.url.pathname; + if (redirectMap.has(currentPath)) { + return new Response(null, { + status: 308, + headers: { + location: redirectMap.get(currentPath) ?? '' + } + }); + } - return await resolve(event); + return await resolve(event); }; + +const bannerRewriter: Handle = async ({ event, resolve }) => { + const response = await resolve(event, { + transformPageChunk: ({ html }) => html.replace('%aw_banner_key%', BANNER_KEY) + }); + return response; +}; + +export const handle = sequence(redirecter, bannerRewriter); diff --git a/src/lib/constants.ts b/src/lib/constants.ts new file mode 100644 index 0000000000..bbbcc6c7b7 --- /dev/null +++ b/src/lib/constants.ts @@ -0,0 +1 @@ +export const BANNER_KEY = 'discord-banner-01'; // Change key to force banner to show again diff --git a/src/lib/layouts/Main.svelte b/src/lib/layouts/Main.svelte index 163672e7ba..f7ee35aaa3 100644 --- a/src/lib/layouts/Main.svelte +++ b/src/lib/layouts/Main.svelte @@ -11,13 +11,12 @@ @@ -168,26 +164,25 @@ class="aw-main-header is-special-padding theme-{resolvedTheme} is-transparent" class:is-hidden={$isHeaderHidden} > - {#if showTopBanner} -
- +
+ - {/if} +
+
diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts deleted file mode 100644 index 8a12a50c85..0000000000 --- a/src/routes/+layout.server.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { BANNER_KEY } from './api/banner/constants.js'; - -export const prerender = true; - -export const load = async ({ cookies }) => { - return { showBanner: cookies.get(BANNER_KEY) !== 'true' }; -}; diff --git a/src/routes/api/banner/+server.ts b/src/routes/api/banner/+server.ts deleted file mode 100644 index 0dc72f3114..0000000000 --- a/src/routes/api/banner/+server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { BANNER_KEY } from './constants.js'; - -export const POST = ({ cookies }) => { - cookies.set(BANNER_KEY, 'true', { - path: '/' - }); - - return new Response(null, { - status: 200 - }); -}; diff --git a/src/routes/api/banner/constants.ts b/src/routes/api/banner/constants.ts deleted file mode 100644 index 41bf2f8e73..0000000000 --- a/src/routes/api/banner/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const BANNER_KEY = 'discord-banner-00'; // Change key to force banner to show again diff --git a/src/routes/api/blog/+server.ts b/src/routes/api/blog/+server.ts deleted file mode 100644 index a5c44e3ee1..0000000000 --- a/src/routes/api/blog/+server.ts +++ /dev/null @@ -1,28 +0,0 @@ -const isVercel = process.env.VERCEL === '1'; - -export const prerender = isVercel; - -const parsePosts = (posts: Record) => { - return Object.fromEntries( - Object.entries(posts).map(([key, value]) => { - return [ - key.replace('../../blog/post/', '').replace('/+page.markdoc', ''), - value.frontmatter - ]; - }) - ); -}; - -const posts = parsePosts( - import.meta.glob('../../blog/post/**/*.markdoc', { - eager: true - }) -); - -export const GET = async () => { - return new Response(JSON.stringify({ posts, total: Object.keys(posts).length }), { - headers: { - 'content-type': 'application/json;charset=UTF-8' - } - }); -}; diff --git a/src/scss/7-components/_top-banner.scss b/src/scss/7-components/_top-banner.scss index b5b3f71a46..46623bc1f0 100644 --- a/src/scss/7-components/_top-banner.scss +++ b/src/scss/7-components/_top-banner.scss @@ -6,4 +6,8 @@ background: linear-gradient(94deg, rgba(253, 54, 110, 0.00) 0%, rgba(253, 54, 110, 0.50) 50.82%, rgba(253, 54, 110, 0.00) 100%); &-content { line-height:pxToRem(20); transition:var(--transition); } &-button { position:absolute; inset-inline-end:pxToRem(12); } + + [data-banner-hidden] & { + display: none; + } } \ No newline at end of file diff --git a/svelte.config.js b/svelte.config.js index ba6af2d5fb..5fbadfa3e4 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,8 +11,7 @@ function absoulute(path) { return join(dirname(fileURLToPath(import.meta.url)), path); } -// const isVercel = process.env.VERCEL === '1'; -const isVercel = true; +const isVercel = process.env.VERCEL === '1'; const adapter = isVercel ? staticAdapter({ strict: false, pages: 'public' }) : nodeAdapter(); From d9a1c4f6b364011250f1254acb15538fe6941401 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:35:54 +0000 Subject: [PATCH 09/10] remove strict --- svelte.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svelte.config.js b/svelte.config.js index 5fbadfa3e4..61e453216d 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -13,7 +13,7 @@ function absoulute(path) { const isVercel = process.env.VERCEL === '1'; -const adapter = isVercel ? staticAdapter({ strict: false, pages: 'public' }) : nodeAdapter(); +const adapter = isVercel ? staticAdapter() : nodeAdapter(); /** @type {import('@sveltejs/kit').Config}*/ const config = { From fb7e7e9f8b85e68eb42dcd2e0d76c96d5cea5457 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:27:48 +0000 Subject: [PATCH 10/10] readd layout server --- src/routes/+layout.server.ts | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/routes/+layout.server.ts diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts new file mode 100644 index 0000000000..189f71e2e1 --- /dev/null +++ b/src/routes/+layout.server.ts @@ -0,0 +1 @@ +export const prerender = true;