type FetchAtBuildProps = {
example: Example;
};
// The component itself.
export default function FetchAtBuild({
example
}: FetchAtBuildProps) {
return (
<div>
<h1>{example.name}</h1>
<p>{example.message}</p>
<p>Created at: {example.createdAt.toDateString()}</p>
<p>Updated at: {example.updatedAt.toDateString()}</p>
</div>
);
}
export const getStaticProps: GetStaticProps<FetchAtBuildProps> = async () => {
try {
const example = await prisma.example.findFirst({
where: {
name: "Example",
},
});
if (!example) {
throw new Error("Example not found");
}
return {
props: {
example,
},
};
} catch (error) {
console.log(error);
throw error;
}
};
type FetchAtBuildProps = {
example: Example;
};
// The component itself.
export default function FetchAtBuild({
example
}: FetchAtBuildProps) {
return (
<div>
<h1>{example.name}</h1>
<p>{example.message}</p>
<p>Created at: {example.createdAt.toDateString()}</p>
<p>Updated at: {example.updatedAt.toDateString()}</p>
</div>
);
}
export const getStaticProps: GetStaticProps<FetchAtBuildProps> = async () => {
try {
const example = await prisma.example.findFirst({
where: {
name: "Example",
},
});
if (!example) {
throw new Error("Example not found");
}
return {
props: {
example,
},
};
} catch (error) {
console.log(error);
throw error;
}
};