refactor: add content block type
This commit is contained in:
parent
8fd9e97144
commit
88390ef919
|
@ -1,9 +1,13 @@
|
|||
import styled from '@emotion/styled'
|
||||
import { Typography } from '@acid-info/lsd-react'
|
||||
import { PostClassType } from '../Post/Post'
|
||||
|
||||
export enum BlockType {
|
||||
TEXT = 'text',
|
||||
IMAGE = 'image',
|
||||
}
|
||||
|
||||
type Props = {
|
||||
type: PostClassType
|
||||
type: BlockType
|
||||
date: string
|
||||
}
|
||||
|
||||
|
@ -11,7 +15,7 @@ const ContentBlockHeader = ({ type, date }: Props) => {
|
|||
return (
|
||||
<ContentBlockInfo>
|
||||
<Typography variant="body3" genericFontFamily="sans-serif">
|
||||
{type.toUpperCase()}
|
||||
{type === BlockType.TEXT ? 'PARAGRAPH' : 'IMAGE'}
|
||||
</Typography>
|
||||
<Typography variant="body3">•</Typography>
|
||||
<Typography variant="body3" genericFontFamily="sans-serif">
|
||||
|
|
|
@ -6,7 +6,7 @@ import { UnbodyImageBlock } from '@/lib/unbody/unbody.types'
|
|||
|
||||
import { GridItem } from '../Grid/Grid'
|
||||
import { PostClassType } from '../Post/Post'
|
||||
import ContentBlockHeader from './ContentBlock.Header'
|
||||
import ContentBlockHeader, { BlockType } from './ContentBlock.Header'
|
||||
import ContentBlockBody from './ContentBlock.Body'
|
||||
import { ResponsiveImage } from '../ResponsiveImage/ResponsiveImage'
|
||||
|
||||
|
@ -20,7 +20,7 @@ const ImageBlock = ({ doc }: Props) => {
|
|||
<Container>
|
||||
<ResponsiveImage data={doc} />
|
||||
<ContentBlockHeader
|
||||
type={PostClassType.ARTICLE}
|
||||
type={BlockType.IMAGE}
|
||||
date={doc?.document[0].modifiedAt}
|
||||
/>
|
||||
<ContentBlockBody
|
||||
|
|
|
@ -7,7 +7,7 @@ import { UnbodyTextBlock } from '@/lib/unbody/unbody.types'
|
|||
import { GridItem } from '../Grid/Grid'
|
||||
import { Typography } from '@acid-info/lsd-react'
|
||||
import { PostClassType } from '../Post/Post'
|
||||
import ContentBlockHeader from './ContentBlock.Header'
|
||||
import ContentBlockHeader, { BlockType } from './ContentBlock.Header'
|
||||
import ContentBlockBody from './ContentBlock.Body'
|
||||
|
||||
type Props = Omit<SearchResultItem<UnbodyTextBlock>, 'score'>
|
||||
|
@ -18,7 +18,7 @@ const TextBlock = ({ doc }: Props) => {
|
|||
<BlockLink href={`/article/${doc.document[0].slug}#p-${doc.order}`}>
|
||||
<Container>
|
||||
<ContentBlockHeader
|
||||
type={PostClassType.ARTICLE}
|
||||
type={BlockType.TEXT}
|
||||
date={doc?.document[0].modifiedAt}
|
||||
/>
|
||||
<Typography variant="body2" genericFontFamily="sans-serif">
|
||||
|
|
Loading…
Reference in New Issue