get-post-slugs.tsx

src/tools/get-post-slugs.tsx
type PostSlugItem = {
slug: string
modified: string
uri: string
}
export async function getPostSlugs(): Promise<{ postSlugs: PostSlugItem[] }> {
const wpJson = (process.env.NEXT_PUBLIC_WORDPRESS_URL ? `${process.env.NEXT_PUBLIC_WORDPRESS_URL}/wp-json` : undefined)
if (!wpJson) return { postSlugs: [] }
const postSlugs: PostSlugItem[] = []
let page = 1
let totalPages = 1
while (page <= totalPages) {
const res = await fetch(
`${wpJson}/wp/v2/posts?_fields=slug,link,modified&per_page=100&page=${page}`,
{ next: { revalidate: 300 } },
)
if (!res.ok) break

Showing the first 20 lines.

Get full code

Support

Talk to the developers of this project to learn more

We have been building professional websites for big clients for over 15 years. Gallop templates and blocks is our best foundation for SEO websites and web apps.

© 2026 Web Plant Media, LLC