const PostPage: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (
{ id }
) => {
...
const postCreatedAt = post ? dateTimeFormatter.format(post.createdAt) : "";
... }
const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
dateStyle: "short",
});
export const getStaticPaths: GetStaticPaths = () => {
return {
paths: [],
fallback: "blocking",
}
}
export async function getStaticProps(context: GetStaticPropsContext<{id: string}>) {
const id = context.params?.id;
if (id == null) {
return {
redirect: {
destination: "/"
}
}
}
const ssg = ssgHelper();
await ssg.post.getById.prefetch({id});
return {
props: {
trpcState: ssg.dehydrate(),
id,
}
}
}
const PostPage: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (
{ id }
) => {
...
const postCreatedAt = post ? dateTimeFormatter.format(post.createdAt) : "";
... }
const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
dateStyle: "short",
});
export const getStaticPaths: GetStaticPaths = () => {
return {
paths: [],
fallback: "blocking",
}
}
export async function getStaticProps(context: GetStaticPropsContext<{id: string}>) {
const id = context.params?.id;
if (id == null) {
return {
redirect: {
destination: "/"
}
}
}
const ssg = ssgHelper();
await ssg.post.getById.prefetch({id});
return {
props: {
trpcState: ssg.dehydrate(),
id,
}
}
}