fix issue with ssg for resources

This commit is contained in:
Brandon Egger
2023-05-18 20:59:39 -05:00
parent a174aafbf2
commit 9fb09d9585
2 changed files with 22 additions and 7 deletions

View File

@ -1,6 +1,6 @@
import { type InferGetStaticPropsType, type GetStaticPropsContext } from "next";
import { GlobeAltIcon, DocumentIcon } from "@heroicons/react/24/solid";
import { createProxySSGHelpers } from "@trpc/react-query/ssg";
import { createServerSideHelpers } from "@trpc/react-query/server";
import { appRouter } from "~/server/api/root";
import { prisma } from "~/server/db";
import { api } from "~/utils/api";
@ -31,20 +31,21 @@ export const getStaticPaths = async () => {
export async function getStaticProps(
context: GetStaticPropsContext<{ id: string }>
) {
const ssg = createProxySSGHelpers({
const helpers = createServerSideHelpers({
router: appRouter,
ctx: {
prisma,
session: null,
},
});
const id = context.params?.id as string;
await ssg.auditoryResource.byId.prefetch({ id });
await helpers.auditoryResource.byId.prefetch({ id });
return {
props: {
trpcState: ssg.dehydrate(),
trpcState: helpers.dehydrate(),
id,
},
revalidate: 1,