3pages
This commit is contained in:
parent
3c2decd505
commit
275310120b
3 changed files with 14 additions and 60 deletions
|
|
@ -13,28 +13,10 @@ 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'
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
|
|
||||||
|
|
@ -15,24 +15,10 @@ 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'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const payload = await getPayload({ config: configPromise })
|
return []
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,11 @@ import React from 'react'
|
||||||
import PageClient from './page.client'
|
import PageClient from './page.client'
|
||||||
import { notFound } from 'next/navigation'
|
import { notFound } from 'next/navigation'
|
||||||
|
|
||||||
export const revalidate = 600
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
export async function generateStaticParams() {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
|
|
@ -68,21 +72,3 @@ export async function generateMetadata({ params: paramsPromise }: Args): Promise
|
||||||
title: `Payload Website Template Posts Page ${pageNumber || ''}`,
|
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
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue