feat: graphql client with fetches for initial pages
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import List from "./Blocks/List"
|
||||
import Preamble from "./Blocks/Preamble"
|
||||
import Puffs from "./Blocks/Puffs"
|
||||
import Text from "./Blocks/Text"
|
||||
|
||||
import { BlocksTypenameEnum } from "@/types/requests/utils/typename"
|
||||
import type { BlocksProps } from "@/types/components/current/blocks"
|
||||
|
||||
export default function Blocks({ blocks }: BlocksProps) {
|
||||
if (!blocks?.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{blocks.map(block => {
|
||||
const type = block.__typename
|
||||
switch (type) {
|
||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksList:
|
||||
return <List key={block.__typename} {...block} />
|
||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksPreamble:
|
||||
return <Preamble key={block.__typename} {...block} />
|
||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs:
|
||||
return <Puffs key={block.__typename} {...block} />
|
||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksText:
|
||||
return <Text key={block.__typename} {...block} />
|
||||
default:
|
||||
console.log(`Unknown type: (${type})`)
|
||||
return null
|
||||
}
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user