chore: [app-router-migration 39] refactor ssr/ssg functions (#13336)
This commit is contained in:
1 parent
5685d343b1
commit
ff1aefe539
21 files changed
+168
-81
No files matched your search
@@ -37,6 +37,7 @@ export type AppProps = Omit<
|
||||
WithNonceProps<{
|
||||
themeBasis?: string;
|
||||
session: Session;
|
||||
i18n?: SSRConfig;
|
||||
}>
|
||||
>
|
||||
>,
|
||||
@@ -108,7 +109,7 @@ const CustomI18nextProvider = (props: AppPropsWithoutNonce) => {
|
||||
}, [locale]);
|
||||
|
||||
const clientViewerI18n = useViewerI18n(locale);
|
||||
const i18n = clientViewerI18n.data?.i18n;
|
||||
const i18n = clientViewerI18n.data?.i18n ?? props.pageProps.i18n;
|
||||
|
||||
const passedProps = {
|
||||
...props,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type GetStaticProps } from "next";
|
||||
import { z } from "zod";
|
||||
|
||||
import { ssgInit } from "@server/lib/ssg";
|
||||
import { getTranslations } from "@server/lib/getTranslations";
|
||||
|
||||
const validStatuses = ["upcoming", "recurring", "past", "cancelled", "unconfirmed"] as const;
|
||||
|
||||
@@ -11,14 +11,14 @@ const querySchema = z.object({
|
||||
|
||||
export const getStaticProps: GetStaticProps = async (ctx) => {
|
||||
const params = querySchema.safeParse(ctx.params);
|
||||
const ssg = await ssgInit(ctx);
|
||||
const i18n = await getTranslations(ctx);
|
||||
|
||||
if (!params.success) return { notFound: true };
|
||||
|
||||
return {
|
||||
props: {
|
||||
status: params.data.status,
|
||||
trpcState: ssg.dehydrate(),
|
||||
i18n,
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user