This commit is contained in:
Mackie 2026-05-22 04:04:21 +08:00
parent 3c2decd505
commit 275310120b
3 changed files with 14 additions and 60 deletions

View file

@ -13,28 +13,10 @@ import { generateMeta } from '@/utilities/generateMeta'
import PageClient from './page.client'
import { LivePreviewListener } from '@/components/LivePreviewListener'
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 = {
@ -110,4 +92,4 @@ const queryPageBySlug = cache(async ({ slug }: { slug: string }) => {
})
return result.docs?.[0] || null
})
})

View file

@ -15,24 +15,10 @@ import { generateMeta } from '@/utilities/generateMeta'
import PageClient from './page.client'
import { LivePreviewListener } from '@/components/LivePreviewListener'
export const dynamic = 'force-dynamic'
export async function generateStaticParams() {
const payload = await getPayload({ config: configPromise })
const posts = await payload.find({
collection: 'posts',
draft: false,
limit: 1000,
overrideAccess: false,
pagination: false,
select: {
slug: true,
},
})
const params = posts.docs.map(({ slug }) => {
return { slug }
})
return params
return []
}
type Args = {
@ -105,4 +91,4 @@ const queryPostBySlug = cache(async ({ slug }: { slug: string }) => {
})
return result.docs?.[0] || null
})
})

View file

@ -9,7 +9,11 @@ import React from 'react'
import PageClient from './page.client'
import { notFound } from 'next/navigation'
export const revalidate = 600
export const dynamic = 'force-dynamic'
export async function generateStaticParams() {
return []
}
type Args = {
params: Promise<{
@ -67,22 +71,4 @@ export async function generateMetadata({ params: paramsPromise }: Args): Promise
return {
title: `Payload Website Template Posts Page ${pageNumber || ''}`,
}
}
export async function generateStaticParams() {
const payload = await getPayload({ config: configPromise })
const { totalDocs } = await payload.count({
collection: 'posts',
overrideAccess: false,
})
const totalPages = Math.ceil(totalDocs / 10)
const pages: { pageNumber: string }[] = []
for (let i = 1; i <= totalPages; i++) {
pages.push({ pageNumber: String(i) })
}
return pages
}
}