export const getStaticProps: GetStaticProps = async (ctx) => {
const ssg = await createServerSideHelpers({
router: appRouter,
ctx: await createContext(),
transformer: superjson,
});
await ssg.public.product.prefetch({
slug: ctx.params?.slug as string,
});
const product = ssg.dehydrate().json.queries[0].state.data;
if (!product) {
return {
notFound: true,
};
}
return {
props: {
trpcState: ssg.dehydrate(),
slug: ctx.params?.slug,
},
};
};
export const getStaticProps: GetStaticProps = async (ctx) => {
const ssg = await createServerSideHelpers({
router: appRouter,
ctx: await createContext(),
transformer: superjson,
});
await ssg.public.product.prefetch({
slug: ctx.params?.slug as string,
});
const product = ssg.dehydrate().json.queries[0].state.data;
if (!product) {
return {
notFound: true,
};
}
return {
props: {
trpcState: ssg.dehydrate(),
slug: ctx.params?.slug,
},
};
};