This commit is contained in:
31
src/components/Blocks/index.tsx
Normal file
31
src/components/Blocks/index.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
import Author from './Author'
|
||||
|
||||
export type AdditionalBlockProps = {
|
||||
blockIndex: number
|
||||
locale: string
|
||||
}
|
||||
|
||||
const blockComponents = {
|
||||
Author: Author,
|
||||
}
|
||||
|
||||
const Blocks = ({ blocks, locale }: any) => {
|
||||
return (
|
||||
<>
|
||||
{blocks
|
||||
?.filter(
|
||||
(block: any) =>
|
||||
block && block.blockType && blockComponents.hasOwnProperty(block.blockType),
|
||||
)
|
||||
.map((block: any, ix: number) => {
|
||||
// @ts-ignore
|
||||
const BlockComponent = blockComponents[block.blockType] ?? null
|
||||
return BlockComponent ? (
|
||||
<BlockComponent key={ix} {...block} blockIndex={ix} locale={locale} />
|
||||
) : null
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Blocks
|
||||
Reference in New Issue
Block a user