refactor: add content block type

This commit is contained in:
jinhojang6 2023-05-14 20:22:07 +09:00 committed by Jinho Jang
parent 8fd9e97144
commit 88390ef919
3 changed files with 11 additions and 7 deletions

View File

@ -1,9 +1,13 @@
import styled from '@emotion/styled' import styled from '@emotion/styled'
import { Typography } from '@acid-info/lsd-react' import { Typography } from '@acid-info/lsd-react'
import { PostClassType } from '../Post/Post'
export enum BlockType {
TEXT = 'text',
IMAGE = 'image',
}
type Props = { type Props = {
type: PostClassType type: BlockType
date: string date: string
} }
@ -11,7 +15,7 @@ const ContentBlockHeader = ({ type, date }: Props) => {
return ( return (
<ContentBlockInfo> <ContentBlockInfo>
<Typography variant="body3" genericFontFamily="sans-serif"> <Typography variant="body3" genericFontFamily="sans-serif">
{type.toUpperCase()} {type === BlockType.TEXT ? 'PARAGRAPH' : 'IMAGE'}
</Typography> </Typography>
<Typography variant="body3"></Typography> <Typography variant="body3"></Typography>
<Typography variant="body3" genericFontFamily="sans-serif"> <Typography variant="body3" genericFontFamily="sans-serif">

View File

@ -6,7 +6,7 @@ import { UnbodyImageBlock } from '@/lib/unbody/unbody.types'
import { GridItem } from '../Grid/Grid' import { GridItem } from '../Grid/Grid'
import { PostClassType } from '../Post/Post' import { PostClassType } from '../Post/Post'
import ContentBlockHeader from './ContentBlock.Header' import ContentBlockHeader, { BlockType } from './ContentBlock.Header'
import ContentBlockBody from './ContentBlock.Body' import ContentBlockBody from './ContentBlock.Body'
import { ResponsiveImage } from '../ResponsiveImage/ResponsiveImage' import { ResponsiveImage } from '../ResponsiveImage/ResponsiveImage'
@ -20,7 +20,7 @@ const ImageBlock = ({ doc }: Props) => {
<Container> <Container>
<ResponsiveImage data={doc} /> <ResponsiveImage data={doc} />
<ContentBlockHeader <ContentBlockHeader
type={PostClassType.ARTICLE} type={BlockType.IMAGE}
date={doc?.document[0].modifiedAt} date={doc?.document[0].modifiedAt}
/> />
<ContentBlockBody <ContentBlockBody

View File

@ -7,7 +7,7 @@ import { UnbodyTextBlock } from '@/lib/unbody/unbody.types'
import { GridItem } from '../Grid/Grid' import { GridItem } from '../Grid/Grid'
import { Typography } from '@acid-info/lsd-react' import { Typography } from '@acid-info/lsd-react'
import { PostClassType } from '../Post/Post' import { PostClassType } from '../Post/Post'
import ContentBlockHeader from './ContentBlock.Header' import ContentBlockHeader, { BlockType } from './ContentBlock.Header'
import ContentBlockBody from './ContentBlock.Body' import ContentBlockBody from './ContentBlock.Body'
type Props = Omit<SearchResultItem<UnbodyTextBlock>, 'score'> type Props = Omit<SearchResultItem<UnbodyTextBlock>, 'score'>
@ -18,7 +18,7 @@ const TextBlock = ({ doc }: Props) => {
<BlockLink href={`/article/${doc.document[0].slug}#p-${doc.order}`}> <BlockLink href={`/article/${doc.document[0].slug}#p-${doc.order}`}>
<Container> <Container>
<ContentBlockHeader <ContentBlockHeader
type={PostClassType.ARTICLE} type={BlockType.TEXT}
date={doc?.document[0].modifiedAt} date={doc?.document[0].modifiedAt}
/> />
<Typography variant="body2" genericFontFamily="sans-serif"> <Typography variant="body2" genericFontFamily="sans-serif">