NuxtN
Nuxt2y ago
Philip

sitemap module wont show dynamic routes, routes are empty

we tried to create on root ebene ( /server/api/sitemap/urls.ts ) the following

import { asSitemapUrl, defineSitemapEventHandler } from '#imports'

export default defineSitemapEventHandler(async () => {
  const [pages, sub_pages, instructions] = await Promise.all([
    //
    $fetch("$cdnurl$/items/pages").then((p) =>
      p.data.map((item) => ({
        loc: item.slug,
        _sitemap: "pages",
      }))
    ),
    $fetch(
      "$cdnurl$/items/sub_pages?fields=translations.slug"
    ).then((sp) =>
      sp.data.map((item) => ({
        loc: `/support/${item.translations[0].slug}`,
        _sitemap: "sub_pages",
      }))
    ),
    $fetch(
      "$cdnurl$/items/Instructions?fields=translations.slug"
    ).then((s) =>
      s.data.map((p) => ({
        loc: `/support/${p.translations[0].slug}`,
        _sitemap: "instructions",
      }))
    ),
  ]);

  return [...pages, ...sub_pages, ...instructions].map((p) => asSitemapUrl({
    return { loc: p.url, lastmod: p.updatedAt };
  }));
});


in the images you can see our nuxt config.

its like we wont even get in to the urls.ts file
Bildschirmfoto_2024-06-27_um_11.30.24.png
Bildschirmfoto_2024-06-27_um_11.30.43.png
Was this page helpful?