Created
July 15, 2023 11:06
-
-
Save danielschmid/6aa6b2dff1ca9a272df052ac30f84db8 to your computer and use it in GitHub Desktop.
Typescript Erro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createClient } from "@/prismicio"; | |
import type { | |
InferGetStaticPropsType, | |
GetStaticPropsContext, | |
GetStaticPaths, | |
} from "next"; | |
import Page from "@/components/Page"; | |
type PageProps = InferGetStaticPropsType<typeof getStaticProps>; | |
export default function Pages({ page, navigation }: PageProps) { | |
return <Page page={page} navigation={navigation} />; | |
} | |
export async function getStaticProps({ | |
params, | |
locale, | |
previewData, | |
}: GetStaticPropsContext) { | |
const client = createClient({ previewData }); | |
const navigation = await client.getByUID("navigation", "header", { | |
lang: locale, | |
}); | |
const page = await client.getByUID("page", params.uid, { lang: locale }); | |
return { | |
props: { | |
page, | |
navigation, | |
}, | |
}; | |
} | |
export const getStaticPaths: GetStaticPaths = async () => { | |
const client = createClient(); | |
const pages = await client.getAllByType("page", { lang: "*" }); | |
return { | |
paths: pages.map((page) => { | |
return { | |
params: { uid: page.uid }, | |
locale: page.lang, | |
}; | |
}), | |
fallback: false, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The error is cause by
params.uid
on line 26