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 PageClient from './page.client'
|
||||||
import { LivePreviewListener } from '@/components/LivePreviewListener'
|
import { LivePreviewListener } from '@/components/LivePreviewListener'
|
||||||
|
|
||||||
|
|
||||||
import HeroBackground from '@/components/HeroBackground'
|
import HeroBackground from '@/components/HeroBackground'
|
||||||
import HeroPage from '@/components/HeroPage'
|
import HeroPage from '@/components/HeroPage'
|
||||||
|
|
||||||
export const revalidate = 0
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const payload = await getPayload({ config: configPromise })
|
return []
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Args = {
|
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) {
|
export default async function Page({ params: paramsPromise }: Args) {
|
||||||
const { isEnabled: draft } = await draftMode()
|
const { isEnabled: draft } = await draftMode()
|
||||||
const { slug = 'home' } = await paramsPromise
|
const { slug = 'home' } = await paramsPromise
|
||||||
// Decode to support slugs with special characters
|
|
||||||
const decodedSlug = decodeURIComponent(slug)
|
const decodedSlug = decodeURIComponent(slug)
|
||||||
const url = '/' + decodedSlug
|
const url = '/' + decodedSlug
|
||||||
|
|
||||||
let page: RequiredDataFromCollectionSlug<'pages'> | null
|
let page: RequiredDataFromCollectionSlug<'pages'> | null
|
||||||
|
|
||||||
page = await queryPageBySlug({
|
page = await queryPageBySlug({ slug: decodedSlug })
|
||||||
slug: decodedSlug,
|
|
||||||
})
|
|
||||||
|
|
||||||
// Remove this code once your website is seeded
|
if (!page && decodedSlug === 'home') {
|
||||||
if (decodedSlug === 'home' || decodedSlug === 'home2') {
|
|
||||||
page = homeStatic
|
page = homeStatic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,15 +51,16 @@ export default async function Page({ params: paramsPromise }: Args) {
|
||||||
|
|
||||||
const { hero, layout } = page
|
const { hero, layout } = page
|
||||||
|
|
||||||
|
// Landing page layout — canvas + hero section with border lines
|
||||||
if (decodedSlug === 'home') {
|
if (LANDING_PAGE_SLUGS.includes(decodedSlug)) {
|
||||||
return (
|
return (
|
||||||
<HeroPage richText={hero.richText} links={hero.links}>
|
<HeroPage richText={hero.richText} links={hero.links}>
|
||||||
<RenderBlocks blocks={layout} />
|
<RenderBlocks blocks={layout} />
|
||||||
</HeroPage>
|
</HeroPage>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All other pages — canvas background + standard content
|
||||||
return (
|
return (
|
||||||
<div style={{ position: 'relative', minHeight: '100vh' }}>
|
<div style={{ position: 'relative', minHeight: '100vh' }}>
|
||||||
<div style={{ position: 'fixed', inset: 0, zIndex: 0 }}>
|
<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> {
|
export async function generateMetadata({ params: paramsPromise }: Args): Promise<Metadata> {
|
||||||
const { slug = 'home' } = await paramsPromise
|
const { slug = 'home' } = await paramsPromise
|
||||||
// Decode to support slugs with special characters
|
|
||||||
const decodedSlug = decodeURIComponent(slug)
|
const decodedSlug = decodeURIComponent(slug)
|
||||||
const page = await queryPageBySlug({
|
const page = await queryPageBySlug({ slug: decodedSlug })
|
||||||
slug: decodedSlug,
|
|
||||||
})
|
|
||||||
|
|
||||||
return generateMeta({ doc: page })
|
return generateMeta({ doc: page })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue