src/tools/get-category-slugs.tsxtype CategorySlug = {slug: stringuri: string}export async function getCategorySlugs(): Promise<{categorySlugs: CategorySlug[]}> {const wpJson = (process.env.NEXT_PUBLIC_WORDPRESS_URL ? `${process.env.NEXT_PUBLIC_WORDPRESS_URL}/wp-json` : undefined)if (!wpJson) return { categorySlugs: [] }const categorySlugs: CategorySlug[] = []let page = 1let totalPages = 1while (page <= totalPages) {const res = await fetch(`${wpJson}/wp/v2/categories?_fields=slug&hide_empty=true&per_page=100&page=${page}`,{ next: { revalidate: 300 } },)
Showing the first 20 lines.
Get full code