+1
-1
src/routes/+layout.svelte
+1
-1
src/routes/+layout.svelte
+13
-20
src/routes/+layout.ts
+13
-20
src/routes/+layout.ts
···
1
import type { LayoutLoad } from './$types';
2
import { createSiteMeta, type SiteMetadata, defaultSiteMeta } from '$lib/helper/siteMeta';
3
-
import { fetchProfile, fetchSiteInfo } from '$lib/services/atproto';
4
5
-
export const load: LayoutLoad = async ({ url, fetch }) => {
6
// Provide the default site metadata
7
const siteMeta: SiteMetadata = createSiteMeta({
8
title: defaultSiteMeta.title,
···
10
url: url.href // Include current URL for proper OG tags
11
});
12
13
-
// Fetch lightweight public data for layout using injected fetch
14
-
let profile = null;
15
-
let siteInfo = null;
16
-
17
-
try {
18
-
profile = await fetchProfile(fetch);
19
-
} catch (err) {
20
-
// Non-fatal: layout should still render even if profile fails
21
-
console.warn('Layout: failed to fetch profile in load', err);
22
-
}
23
-
24
-
try {
25
-
siteInfo = await fetchSiteInfo(fetch);
26
-
} catch (err) {
27
-
console.warn('Layout: failed to fetch siteInfo in load', err);
28
-
}
29
-
30
-
return { siteMeta, profile, siteInfo };
31
};
···
1
import type { LayoutLoad } from './$types';
2
import { createSiteMeta, type SiteMetadata, defaultSiteMeta } from '$lib/helper/siteMeta';
3
4
+
/**
5
+
* Non-blocking layout load
6
+
* Returns immediately with default site metadata
7
+
* All data fetching happens client-side in components for faster initial page load
8
+
*/
9
+
export const load: LayoutLoad = async ({ url }) => {
10
// Provide the default site metadata
11
const siteMeta: SiteMetadata = createSiteMeta({
12
title: defaultSiteMeta.title,
···
14
url: url.href // Include current URL for proper OG tags
15
});
16
17
+
// Return immediately - no blocking data fetches
18
+
// Components will fetch their own data client-side with skeletons
19
+
return {
20
+
siteMeta,
21
+
profile: null,
22
+
siteInfo: null
23
+
};
24
};