refactor: add content block type
This commit is contained in:
parent
8fd9e97144
commit
88390ef919
|
@ -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">
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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">
|
||||||
|
|
Loading…
Reference in New Issue