|
| 1 | +import 'dayjs/locale/ko'; |
| 2 | + |
| 3 | +import dayjs from 'dayjs'; |
| 4 | +import { getTranslations } from 'next-intl/server'; |
| 5 | + |
| 6 | +import { CouncilReport } from '@/apis/types/council'; |
| 7 | +import PostFooter from '@/app/[locale]/community/components/PostFooter'; |
| 8 | +import { StraightNode } from '@/components/common/Nodes'; |
| 9 | +import HTMLViewer from '@/components/form/html/HTMLViewer'; |
| 10 | +import { PAGE_PADDING_BOTTOM_TAILWIND } from '@/components/layout/pageLayout/paddings'; |
1 | 11 | import PageLayout from '@/components/layout/pageLayout/PageLayout'; |
| 12 | +import { councilReportList } from '@/constants/segmentNode'; |
| 13 | +import { getMetadata } from '@/utils/metadata'; |
| 14 | + |
| 15 | +const council: CouncilReport = { |
| 16 | + id: 2, |
| 17 | + title: 'title', |
| 18 | + description: 'description', |
| 19 | + sequence: 1, |
| 20 | + name: 'name', |
| 21 | + createdAt: '2022-01-01T00:00:00.000Z', |
| 22 | + prevId: 1, |
| 23 | + prevTitle: 'prevTitle', |
| 24 | + nextId: 3, |
| 25 | + nextTitle: 'nextTitle', |
| 26 | +}; |
| 27 | + |
| 28 | +interface Props { |
| 29 | + params: Promise<{ id: number; locale: string }>; |
| 30 | +} |
| 31 | + |
| 32 | +export async function generateMetadata({ params }: Props) { |
| 33 | + const { locale } = await params; |
| 34 | + // const { title } = await getCouncilReport(id); |
| 35 | + const { title } = council; |
| 36 | + |
| 37 | + return await getMetadata({ |
| 38 | + locale, |
| 39 | + node: councilReportList, |
| 40 | + metadata: { title }, |
| 41 | + }); |
| 42 | +} |
| 43 | + |
| 44 | +export default async function CouncilReportPage({ params }: Props) { |
| 45 | + const { id, locale } = await params; |
| 46 | + const t = await getTranslations({ locale }); |
| 47 | + |
| 48 | + // const council = await getCouncilReport(id); |
| 49 | + |
| 50 | + const { title, description, sequence, name, createdAt } = council; |
| 51 | + const author = `제${sequence}대 학생회 ${name}`; |
| 52 | + const dateStr = dayjs(createdAt).locale('ko').format('YYYY/MM/DD (ddd) A h:mm'); |
| 53 | + |
| 54 | + return ( |
| 55 | + <PageLayout titleType="big" removePadding> |
| 56 | + <div className="flex flex-col gap-4 px-5 py-9 sm:pl-[100px] sm:pr-[340px]"> |
| 57 | + <h2 className="text-[1.25rem] font-semibold leading-[1.4]">{title}</h2> |
| 58 | + <div className="flex gap-5 text-sm font-normal tracking-wide text-neutral-500"> |
| 59 | + <p> |
| 60 | + {t('작성자')}: {author} |
| 61 | + </p> |
| 62 | + <p> |
| 63 | + {t('작성 날짜')}: {dateStr} |
| 64 | + </p> |
| 65 | + </div> |
| 66 | + </div> |
2 | 67 |
|
3 | | -export default function CouncilReport({ params: { id } }: { params: { id: number } }) { |
4 | | - return <PageLayout titleType="big">CouncilReport {id}</PageLayout>; |
| 68 | + <div |
| 69 | + className={`bg-neutral-50 px-5 pt-9 sm:pl-[100px] sm:pr-[340px] ${PAGE_PADDING_BOTTOM_TAILWIND}`} |
| 70 | + > |
| 71 | + <HTMLViewer htmlContent={description} wrapperClassName="mb-10" /> |
| 72 | + <StraightNode /> |
| 73 | + <PostFooter post={council} postType="council/report" id={id.toString()} margin="mt-12" /> |
| 74 | + </div> |
| 75 | + </PageLayout> |
| 76 | + ); |
5 | 77 | } |
0 commit comments