-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from appwrite/fix-flicker
Fix FOUC
- Loading branch information
Showing
9 changed files
with
71 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const BANNER_KEY = 'discord-banner-01'; // Change key to force banner to show again |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/routes/docs/references/[version]/[platform]/[service]/+layout.svelte
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters