import { GetServerSideProps, NextPage } from 'next'; import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult'; import getBeerPostById from '@/services/BeerPost/getBeerPostById'; import Layout from '@/components/ui/Layout'; import Head from 'next/head'; import Image from 'next/image'; import BeerInfoHeader from '@/components/BeerById/BeerInfoHeader'; import CommentCard from '@/components/BeerById/CommentCard'; interface BeerPageProps { beerPost: BeerPostQueryResult; } const BeerByIdPage: NextPage = ({ beerPost }) => { return ( {beerPost.name}
{beerPost.beerImages[0] && ( {beerPost.beerImages[0].alt} )}
{beerPost.beerComments.map((comment) => ( ))}
); }; export const getServerSideProps: GetServerSideProps = async (context) => { const beerPost = await getBeerPostById(context.params!.id! as string); return !beerPost ? { notFound: true } : { props: { beerPost: JSON.parse(JSON.stringify(beerPost)) } }; }; export default BeerByIdPage;