Skip to content

Instantly share code, notes, and snippets.

@danielschmid
Created July 15, 2023 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielschmid/6aa6b2dff1ca9a272df052ac30f84db8 to your computer and use it in GitHub Desktop.
Save danielschmid/6aa6b2dff1ca9a272df052ac30f84db8 to your computer and use it in GitHub Desktop.
Typescript Erro
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,
};
};
@danielschmid
Copy link
Author

The error is cause by params.uid on line 26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment