hero
This commit is contained in:
parent
f01df5a60f
commit
91aeaef27d
1 changed files with 19 additions and 42 deletions
|
|
@ -13,34 +13,13 @@ import { generateMeta } from '@/utilities/generateMeta'
|
|||
import PageClient from './page.client'
|
||||
import { LivePreviewListener } from '@/components/LivePreviewListener'
|
||||
|
||||
|
||||
import HeroBackground from '@/components/HeroBackground'
|
||||
import HeroPage from '@/components/HeroPage'
|
||||
|
||||
export const revalidate = 0
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const payload = await getPayload({ config: configPromise })
|
||||
const pages = await payload.find({
|
||||
collection: 'pages',
|
||||
draft: false,
|
||||
limit: 1000,
|
||||
overrideAccess: false,
|
||||
pagination: false,
|
||||
select: {
|
||||
slug: true,
|
||||
},
|
||||
})
|
||||
|
||||
const params = pages.docs
|
||||
?.filter((doc) => {
|
||||
return doc.slug !== 'home'
|
||||
})
|
||||
.map(({ slug }) => {
|
||||
return { slug }
|
||||
})
|
||||
|
||||
return params
|
||||
return []
|
||||
}
|
||||
|
||||
type Args = {
|
||||
|
|
@ -49,20 +28,20 @@ type Args = {
|
|||
}>
|
||||
}
|
||||
|
||||
// Add any slugs here that should use the landing page layout
|
||||
const LANDING_PAGE_SLUGS = ['home']
|
||||
|
||||
export default async function Page({ params: paramsPromise }: Args) {
|
||||
const { isEnabled: draft } = await draftMode()
|
||||
const { slug = 'home' } = await paramsPromise
|
||||
// Decode to support slugs with special characters
|
||||
const decodedSlug = decodeURIComponent(slug)
|
||||
const url = '/' + decodedSlug
|
||||
|
||||
let page: RequiredDataFromCollectionSlug<'pages'> | null
|
||||
|
||||
page = await queryPageBySlug({
|
||||
slug: decodedSlug,
|
||||
})
|
||||
page = await queryPageBySlug({ slug: decodedSlug })
|
||||
|
||||
// Remove this code once your website is seeded
|
||||
if (decodedSlug === 'home' || decodedSlug === 'home2') {
|
||||
if (!page && decodedSlug === 'home') {
|
||||
page = homeStatic
|
||||
}
|
||||
|
||||
|
|
@ -72,15 +51,16 @@ export default async function Page({ params: paramsPromise }: Args) {
|
|||
|
||||
const { hero, layout } = page
|
||||
|
||||
// Landing page layout — canvas + hero section with border lines
|
||||
if (LANDING_PAGE_SLUGS.includes(decodedSlug)) {
|
||||
return (
|
||||
<HeroPage richText={hero.richText} links={hero.links}>
|
||||
<RenderBlocks blocks={layout} />
|
||||
</HeroPage>
|
||||
)
|
||||
}
|
||||
|
||||
if (decodedSlug === 'home') {
|
||||
return (
|
||||
<HeroPage richText={hero.richText} links={hero.links}>
|
||||
<RenderBlocks blocks={layout} />
|
||||
</HeroPage>
|
||||
)
|
||||
}
|
||||
|
||||
// All other pages — canvas background + standard content
|
||||
return (
|
||||
<div style={{ position: 'relative', minHeight: '100vh' }}>
|
||||
<div style={{ position: 'fixed', inset: 0, zIndex: 0 }}>
|
||||
|
|
@ -99,11 +79,8 @@ export default async function Page({ params: paramsPromise }: Args) {
|
|||
|
||||
export async function generateMetadata({ params: paramsPromise }: Args): Promise<Metadata> {
|
||||
const { slug = 'home' } = await paramsPromise
|
||||
// Decode to support slugs with special characters
|
||||
const decodedSlug = decodeURIComponent(slug)
|
||||
const page = await queryPageBySlug({
|
||||
slug: decodedSlug,
|
||||
})
|
||||
const page = await queryPageBySlug({ slug: decodedSlug })
|
||||
|
||||
return generateMeta({ doc: page })
|
||||
}
|
||||
|
|
@ -127,4 +104,4 @@ const queryPageBySlug = cache(async ({ slug }: { slug: string }) => {
|
|||
})
|
||||
|
||||
return result.docs?.[0] || null
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Reference in a new issue