Hey
@615584606346805278I suggest you take a look at this discussion and see if this helps in your case—
According to this, I need to add something to the docker file. I am not sure what I should add.
I added this to the app directory.
the content of route.ts is:
export const dynamic = 'force-dynamic'
Can you help me with this?
@364562745447940099it's not specific to Payload, you need to generate sitemap using this Next.js guide.
You can get the data for sitemap with REST / GraphQL or Local API if using 3.0
It could look like this
import type { MetadataRoute } from 'next'
const serverUrl = 'https://domain.com'
export default async function sitemap(): MetadataRoute.Sitemap {
const { docs: pages } = await fetch(`${serverUrl}/api/pages?limit=0`).then((res) => res.json())
const { docs: posts } = await fetch(`${serverUrl}/api/posts?limit=0`).then((res) =>
res.json(),
)
const sitemap: MetadataRoute.Sitemap = []
for (const page of pages) {
sitemap.push({
changeFrequency: 'monthly',
lastModified: page.updatedAt,
priority: 1,
url: `${serverUrl}/${page.slug === 'home' ? '' : page.slug}`,
})
}
for (const post of posts) {
sitemap.push({
changeFrequency: 'monthly',
lastModified: post.updatedAt,
priority: 1,
url: `${serverUrl}/posts/${post.slug}`,
})
}
return sitemap
}
thank you for jumping in here!
Where should I put this piece of code? Obviously, I have to edit it based on my requirement, but, where should it reside in the project? And how can I access the sitemap once its been generated.
I already referred to this docs but didnt help much, as it doesn't incorporate payload
this is a screenshot from Next.js docs, so you should put this into
app/sitemap.ts
Worked!
Thank you so much!
Is there any plugin for handling it?
Star
Discord
online
Get dedicated engineering support directly from the Payload team.