refactor(web-next): thin app pages that just render feature components
Pages import feature server components and pass only route-derived props (slug, id). All data fetching, prefetch, and hydration is owned by the feature's .server.tsx component.
This commit is contained in:
@@ -1,35 +1,12 @@
|
||||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import { appRouter } from "@repo/core-api";
|
||||
import { getQueryClient } from "@repo/core-trpc";
|
||||
import { PageContent } from "@repo/marketing-pages/ui";
|
||||
import { bindAll } from "../../server/bind-production";
|
||||
|
||||
export default async function AboutPage() {
|
||||
const caller = appRouter.createCaller({});
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const page = await caller.marketingPages.pageBySlug({ slug: "about" });
|
||||
|
||||
queryClient.setQueryData(
|
||||
["marketingPages", "pageBySlug", { input: { slug: "about" } }],
|
||||
page,
|
||||
);
|
||||
|
||||
if (!page) {
|
||||
return (
|
||||
<main className="mx-auto max-w-3xl px-6 py-8">
|
||||
<h1 className="text-3xl font-bold text-foreground">About</h1>
|
||||
<p className="mt-2 text-muted-foreground">
|
||||
This page hasn't been published yet.
|
||||
</p>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
await bindAll();
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<main className="px-6 py-8">
|
||||
<PageContent slug="about" />
|
||||
</main>
|
||||
</HydrationBoundary>
|
||||
<main className="px-6 py-8">
|
||||
<PageContent slug="about" />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user