Skip to content

Commit db84505

Browse files
committed
feat: get action page to render other blocks
1 parent 6590e49 commit db84505

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/app/(landing)/[locale]/actions/page.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
import { ActionsPageClient } from "@/components/ActionsPageClient"
21
import { Aurora } from "@/components/ui/Aurora"
32
import { LandingContainer } from "@/components/ui/LandingContainer"
3+
import { PageBlocks } from "@/components/PageBlockRenderer"
44
import { createLandingMetadata, getPageLocale, type LocalePageParams } from "@/lib/appRoute"
55
import { getActions, getLandingPage } from "@/lib/cms"
6-
import { findPageBlock } from "@/lib/pageBlocks"
76

87
export const generateMetadata = createLandingMetadata("actions")
98

109
export default async function ActionsPage({ params }: { params: LocalePageParams }) {
1110
const locale = await getPageLocale(params)
12-
const [actions, actionsPage] = await Promise.all([
13-
getActions(locale),
14-
getLandingPage("actions", locale),
15-
])
16-
const actionsBlock = findPageBlock(actionsPage, "actions")
11+
const [actions, actionsPage] = await Promise.all([getActions(locale), getLandingPage("actions", locale)])
1712

1813
return (
1914
<>
2015
<Aurora />
21-
<LandingContainer className="pt-32">
22-
<ActionsPageClient actions={actions} locale={locale} content={actionsBlock} />
16+
<LandingContainer>
17+
<div className="h-12 lg:h-16" aria-hidden="true" />
18+
<PageBlocks blocks={actionsPage?.layout} actions={actions} locale={locale} />
2319
</LandingContainer>
2420
</>
2521
)

src/components/PageBlockRenderer.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@ import { StandaloneCardSection } from "./sections/StandaloneCardSection"
2020
import { VideoSection } from "./sections/VideoSection"
2121
import { WideHeroSection } from "./sections/WideHeroSection"
2222
import { StatsSection } from "./sections/StatsSection"
23+
import { ActionsPageClient } from "./ActionsPageClient"
24+
import type { ActionItem } from "@/lib/cms"
2325

2426
type PageBlock = NonNullable<Page["layout"]>[number]
2527

2628
interface PageBlocksRendererProps {
2729
blocks?: PageBlock[] | null
30+
actions?: ActionItem[]
2831
cardRowChildren?: ReactNode
2932
ctaFloating?: boolean
3033
locale?: AppLocale
3134
}
3235

33-
type PageBlockRenderOptions = Pick<PageBlocksRendererProps, "cardRowChildren" | "ctaFloating" | "locale">
36+
type PageBlockRenderOptions = Pick<PageBlocksRendererProps, "actions" | "cardRowChildren" | "ctaFloating" | "locale">
3437
type BlockRenderer = (block: PageBlock, options: PageBlockRenderOptions) => ReactNode
3538

3639
const pageBlockRenderers: Partial<Record<PageBlock["blockType"], BlockRenderer>> = {
@@ -53,17 +56,18 @@ const pageBlockRenderers: Partial<Record<PageBlock["blockType"], BlockRenderer>>
5356
widehero: (block) => <WideHeroSection content={block as Extract<PageBlock, { blockType: "widehero" }>} />,
5457
listFeature: (block) => <ListFeatureSection content={block as Extract<PageBlock, { blockType: "listFeature" }>} />,
5558
stats: (block) => <StatsSection content={block as Extract<PageBlock, { blockType: "stats" }>} />,
59+
actions: (block, options) => <ActionsPageClient actions={options.actions ?? []} locale={options.locale ?? "en"} content={block as Extract<PageBlock, { blockType: "actions" }>} />,
5660
}
5761

5862
function renderPageBlock(block: PageBlock, options: PageBlockRenderOptions) {
5963
const renderer = pageBlockRenderers[block.blockType]
6064
return renderer ? renderer(block, options) : null
6165
}
6266

63-
export function PageBlocks({ blocks, cardRowChildren, ctaFloating = false, locale }: PageBlocksRendererProps) {
67+
export function PageBlocks({ blocks, actions, cardRowChildren, ctaFloating = false, locale }: PageBlocksRendererProps) {
6468
const renderableBlocks =
6569
blocks?.flatMap((block) => {
66-
const element = renderPageBlock(block, { cardRowChildren, ctaFloating, locale })
70+
const element = renderPageBlock(block, { actions, cardRowChildren, ctaFloating, locale })
6771
return element ? [{ block, element }] : []
6872
}) ?? []
6973

0 commit comments

Comments
 (0)