Why is it not working to create an image section in my sitemap?

20 Views Asked by At

How i can to add a image (lic, caption, title) on my sitemap?

I tried

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
  const products = await getProducts();
  const formattedProducts =
    products.map((product) => {
      return {
        url: `${process.env.ADMIN_ENDPOINT_BACKEND}/products/${product._id}`,
        lastModified: new Date(),
        changeFrequency: EnumChangefreq.weekly,
        priority: 1,
        images: [
          {
            loc: {
              href: `${process.env.ADMIN_ENDPOINT_BACKEND}/images/${product.image}`,
            },
            caption: product.title,
            title: product.title,
          },
        ],
      };
    }) ?? [];

  return [
    ...formattedProducts,
  ];
}

but it`s doesnt work, what i need to do?

0

There are 0 best solutions below