Skip to content

Commit b8a467c

Browse files
authored
feat(app2): get edition on load (#4491)
2 parents 445745b + 46080c9 commit b8a467c

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

app2/src/routes/+layout.svelte

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import "../app.css"
3-
import { onMount } from "svelte"
3+
import { onMount, type Snippet } from "svelte"
44
import { Effect, Fiber, Option } from "effect"
55
import { chainsQuery } from "$lib/queries/chains.svelte"
66
import Sidebar from "$lib/components/layout/Sidebar/index.svelte"
@@ -19,8 +19,14 @@ import { runFork } from "$lib/utils/effect.svelte"
1919
import { keyboardShortcuts } from "$lib/stores/shortcuts.svelte"
2020
import Seo from "$lib/components/Seo.svelte"
2121
import { interceptLogos } from "$lib/utils/intercept-logos.ts"
22+
import type { PageData } from "./$types.ts"
2223
23-
let { children } = $props()
24+
interface Props {
25+
children: Snippet
26+
data: PageData
27+
}
28+
29+
let { children, data }: Props = $props()
2430
2531
/* Hack to be able to JSON.stringify BigInt */
2632
interface BigInt {
@@ -31,21 +37,8 @@ BigInt["prototype"].toJSON = function () {
3137
return this.toString()
3238
}
3339
34-
$effect(() => {
35-
const hostname = page.url.hostname
36-
// Clear any existing override when hostname changes
37-
uiStore.overrideEdition = null
38-
39-
if (hostname.startsWith("btc.") || hostname.startsWith("staging.btc.")) {
40-
uiStore.edition = "btc"
41-
} else if (hostname.startsWith("app.") || hostname.startsWith("staging.app.")) {
42-
uiStore.edition = "app"
43-
} else {
44-
uiStore.edition = "app"
45-
}
46-
})
47-
4840
onMount(() => {
41+
uiStore.edition = data.edition
4942
interceptLogos()
5043
runExample()
5144
runFork(chainsQuery(ENV()))

app2/src/routes/+layout.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
import type { Edition } from "$lib/themes"
2+
13
export const ssr = false
24
export const prerender = true
35
export const trailingSlash = "ignore"
6+
7+
export const load = ({ url }) => {
8+
const hostname = url.hostname
9+
let edition: Edition = "app"
10+
11+
if (hostname.startsWith("btc.") || hostname.startsWith("staging.btc.")) {
12+
edition = "btc"
13+
} else if (hostname.startsWith("app.") || hostname.startsWith("staging.app.")) {
14+
edition = "app"
15+
}
16+
17+
return {
18+
edition
19+
}
20+
}

0 commit comments

Comments
 (0)