;
+ profile?: ProfileData | null;
+ siteInfo?: SiteInfoData | null;
};
children: Snippet;
}
@@ -75,11 +78,11 @@
-
+
{@render children()}
-
+
diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts
index 1a02308..da231a0 100644
--- a/src/routes/+layout.ts
+++ b/src/routes/+layout.ts
@@ -1,7 +1,8 @@
import type { LayoutLoad } from './$types';
import { createSiteMeta, type SiteMetadata, defaultSiteMeta } from '$lib/helper/siteMeta';
+import { fetchProfile, fetchSiteInfo } from '$lib/services/atproto';
-export const load: LayoutLoad = async ({ url }) => {
+export const load: LayoutLoad = async ({ url, fetch }) => {
// Provide the default site metadata
const siteMeta: SiteMetadata = createSiteMeta({
title: defaultSiteMeta.title,
@@ -9,5 +10,22 @@ export const load: LayoutLoad = async ({ url }) => {
url: url.href // Include current URL for proper OG tags
});
- return { siteMeta };
+ // Fetch lightweight public data for layout using injected fetch
+ let profile = null;
+ let siteInfo = null;
+
+ try {
+ profile = await fetchProfile(fetch);
+ } catch (err) {
+ // Non-fatal: layout should still render even if profile fails
+ console.warn('Layout: failed to fetch profile in load', err);
+ }
+
+ try {
+ siteInfo = await fetchSiteInfo(fetch);
+ } catch (err) {
+ console.warn('Layout: failed to fetch siteInfo in load', err);
+ }
+
+ return { siteMeta, profile, siteInfo };
};
diff --git a/src/routes/site/meta/+page.ts b/src/routes/site/meta/+page.ts
index 6effe61..7c6b686 100644
--- a/src/routes/site/meta/+page.ts
+++ b/src/routes/site/meta/+page.ts
@@ -3,14 +3,14 @@ import { fetchSiteInfo, type SiteInfoData } from '$lib/services/atproto';
import { createSiteMeta, type SiteMetadata, defaultSiteMeta } from '$lib/helper/siteMeta';
import { ogImages } from '$lib/helper/ogImages';
-export const load: PageLoad = async ({ parent }) => {
+export const load: PageLoad = async ({ parent, fetch }) => {
const { siteMeta } = await parent();
let siteInfo: SiteInfoData | null = null;
let error: string | null = null;
- try {
- siteInfo = await fetchSiteInfo();
+ try {
+ siteInfo = await fetchSiteInfo(fetch);
} catch (err) {
error = err instanceof Error ? err.message : 'Failed to load site information';
}