Skip to content

Commit 8f1c8cb

Browse files
sea-snakeaterga
andauthored
SSG (Static Site Generated) landing page (#3397)
* first * Add back reroute to SSG landing page and make title shorter. * Add back reroute to SSG landing page and make title shorter. * Copy over current query params * Copy over current query params * Remove JS from landing page, use css instead. * Fix legacy add remote device. * Reduce canister size. * Update comment --------- Co-authored-by: Arshavir Ter-Gabrielyan <[email protected]>
1 parent c046eeb commit 8f1c8cb

File tree

20 files changed

+127
-112
lines changed

20 files changed

+127
-112
lines changed

src/frontend/src/app.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<link rel="shortcut icon" href="%sveltekit.assets%/favicon.ico" />
6-
<title>
7-
Internet Identity is the login service for the Internet Computer, a fully
8-
decentralized, privacy-preserving, secure, passwordless, biometric
9-
authentication service for ICP applications, powered by blockchain
10-
cryptography.
11-
</title>
6+
<title>Internet Identity</title>
127
<meta
138
name="viewport"
149
content="width=device-width, initial-scale=1, viewport-fit=cover"

src/frontend/src/hooks.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { nonNullish } from "@dfinity/utils";
55
import { DISCOVERABLE_PASSKEY_FLOW } from "$lib/state/featureFlags";
66
import { get } from "svelte/store";
77
import { building } from "$app/environment";
8+
import { goto, replaceState } from "$app/navigation";
89

910
export const reroute: Reroute = ({ url }) => {
1011
if (nonNullish(getAddDeviceAnchor(url))) {
@@ -29,3 +30,27 @@ export const reroute: Reroute = ({ url }) => {
2930
return get(DISCOVERABLE_PASSKEY_FLOW) || building ? "/" : "/legacy";
3031
}
3132
};
33+
34+
// SSG routes don't reroute by default anymore, so this method is used in
35+
// these routes to manually add the rerouting back as early as possible,
36+
// before hydration has even started (so intentionally outside onMount).
37+
export const manuallyReroute = async () => {
38+
if (!building) {
39+
const next = await reroute({
40+
url: new URL(window.location.href),
41+
fetch: window.fetch,
42+
});
43+
if (nonNullish(next)) {
44+
// Capture current URL
45+
const currentURL = new URL(window.location.href);
46+
// Cast to string since `nonNullish` doesn't exclude `void` type
47+
const nextURL = new URL(next as string, window.location.origin);
48+
// Copy over the current query params
49+
nextURL.search = currentURL.search;
50+
// Reroute to destination
51+
await goto(nextURL, { replaceState: true });
52+
// After rerouting, change the URL back to what the user expects to see
53+
replaceState(currentURL, {});
54+
}
55+
}
56+
};

src/frontend/src/lib/components/illustrations/landing/EasyAccessIllustration.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
import type { SVGAttributes } from "svelte/elements";
99
1010
type Props = SVGAttributes<SVGSVGElement> & {
11-
colors: { start: string; end: string };
11+
colors?: { start: string; end: string };
1212
};
1313
14-
const { class: className, colors, ...props }: Props = $props();
14+
const {
15+
class: className,
16+
colors = { start: "currentColor", end: "currentColor" },
17+
...props
18+
}: Props = $props();
1519
</script>
1620

1721
<svg

src/frontend/src/lib/components/illustrations/landing/FullControlIllustration.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
import type { SVGAttributes } from "svelte/elements";
99
1010
type Props = SVGAttributes<SVGSVGElement> & {
11-
colors: { start: string; end: string };
11+
colors?: { start: string; end: string };
1212
};
1313
14-
const { class: className, colors, ...props }: Props = $props();
14+
const {
15+
class: className,
16+
colors = { start: "currentColor", end: "currentColor" },
17+
...props
18+
}: Props = $props();
1519
</script>
1620

1721
<svg

src/frontend/src/lib/components/illustrations/landing/PasswordFreeIllustration.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
import type { SVGAttributes } from "svelte/elements";
99
1010
type Props = SVGAttributes<SVGSVGElement> & {
11-
colors: { start: string; end: string };
11+
colors?: { start: string; end: string };
1212
};
1313
14-
const { class: className, colors, ...props }: Props = $props();
14+
const {
15+
class: className,
16+
colors = { start: "currentColor", end: "currentColor" },
17+
...props
18+
}: Props = $props();
1519
</script>
1620

1721
<svg
-2.55 KB
Loading
-5.5 KB
Loading
-2.48 KB
Loading
-3.66 KB
Loading
-9.63 KB
Binary file not shown.

0 commit comments

Comments
 (0)