Skip to content

Commit

Permalink
feat: 블로그 글 보기 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Tekiter committed Jul 20, 2023
1 parent d8f76ae commit ef0c42f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/web/src/app/blog/article/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { FC } from 'react';

import ArticlePage from '@/components/blog/ArticleDetail';

interface BlogArticlePageProps {
params: { id: string };
}

export const runtime = 'edge';

const BlogArticlePage: FC<BlogArticlePageProps> = ({ params }) => {
return <>{params.id}</>;
return (
<>
<ArticlePage id={params.id} />
</>
);
};

export default BlogArticlePage;
65 changes: 65 additions & 0 deletions apps/web/src/components/blog/ArticleDetail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Link from 'next/link';

import { gateway } from '@/gateway';

import { BlockRenderer } from '../notion/renderer';

interface ArticlePageProps {
id: string;
}

async function ArticlePage({ id }: ArticlePageProps) {
const article = await gateway.blog.article.query({ id });

return (
<div className='flex flex-col items-center'>
<div className='flex w-full max-w-[800px] flex-col px-[16px]'>
<Link href='/blog' className='flex gap-x-[8px] self-start py-[24px] pr-[8px]'>
<BackIcon />
<span className='text-[16px] font-light leading-[20px] text-gray80'>블로그 홈 가기</span>
</Link>
{article.thumbnail && (
<div className='overflow-clip rounded-lg border border-real-white/10 md:rounded-3xl'>
<img src={article.thumbnail.url} alt='Thumbnail Image' />
</div>
)}
<div className='mt-[20px] flex md:mt-[32px]'>
{article.category && (
<>
<Link href={`/blog/category/${article.category}`}>
<span className='rounded-[13px] bg-black80 px-[12px] py-[6px] leading-[120%] text-white100'>
{article.category}
</span>
</Link>
</>
)}
</div>
<h1 className='mt-[12px] break-keep text-[28px] font-bold leading-[130%] text-white100 md:text-[40px]'>
{article.title}
</h1>
<div className='mt-[8px] text-[14px] font-light text-gray60'>
{/* {article.publishedAt && format(article.publishedAt, 'yyyy.MM.dd')} */}
{article.publishedAt.toString()}
</div>
<div className='mt-[40px] md:mt-[80px]'>
<BlockRenderer blocks={article.blocks} renderPageLink={() => <div>Subpage not allowed</div>} />
</div>
</div>
</div>
);
}

export default ArticlePage;

function BackIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg width={20} height={20} fill='none' xmlns='http://www.w3.org/2000/svg' {...props}>
<path
fillRule='evenodd'
clipRule='evenodd'
d='M13.852 2.642a.498.498 0 010 .7L7.194 10l6.658 6.658a.498.498 0 010 .7.498.498 0 01-.7 0L6.144 10.35a.498.498 0 010-.7l7.008-7.008a.498.498 0 01.7 0z'
fill='#808388'
/>
</svg>
);
}

0 comments on commit ef0c42f

Please sign in to comment.