ISR Revalidate app router
Unanswered
Harlequin posted this in #help-forum
HarlequinOP
[...slug]
what am i missing it is not revalidating
import { getPayload } from 'payload'
import configPromise from '@payload-config'
import Link from 'next/link'
export const revalidate = 60
type Props = {
params: {
slug: string[]
}
}
export default async function Page({ params }: Props) {
const payload = await getPayload({ config: configPromise })
const { slug } = params
if (slug.length === 0) {
return (
<div className="text-center mt-16">
<p>This post was not found</p>
<Link href="/blog">
<a className="text-primary underline mt-4">Go to blog</a>
</Link>
</div>
)
}
const singleBlogPost = await payload.find({
collection: 'blog-posts',
where: {
slug: {
equals: slug[0],
},
},
})
if (singleBlogPost.docs.length === 0) {
return (
<div className="text-center mt-16">
<p>This post was not found</p>
<Link href="/blog">
<a className="text-primary underline mt-4">Go to blog</a>
</Link>
</div>
)
}
const post = singleBlogPost.docs[0]
return (
......
}
export async function generateStaticParams() {
const payload = await getPayload({ config: configPromise })
const allBlogPosts = await payload.find({
collection: 'blog-posts',
sort: '-createdAt',
})
return allBlogPosts?.docs?.map((doc) => ({
slug: [doc.slug],
}))
}what am i missing it is not revalidating