I have successfully created a sitemap in Next.js by generating dynamic links in an XML file that look like the code below. I tried to use the same methode to create an XML file that I can submit to Pinterest but they rejected the file because the structure doesn't match theirs. I have no clue how to do this. I want to replace urlset and url by channel and item. Also I'm not sure what are those g:x tags but I don't this this matter that much.
How should I do this?
my XML file in /pinterest-products-sitemap/index.tsx :
import { getServerSideSitemap, ISitemapField } from 'next-sitemap';
import { GetServerSideProps } from 'next';
import {
getProducts,
} from '../../components/Utils/apis';
import {
productsPage
} from '../../components/Utils/pageUrls';
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const resProducts = await fetchAPI(getProducts);
const dataProducts = await resProducts;
const result = []
dataProducts.map(product =>
result.push({
link: `${process.env.FRONT_END_URL}${productsPage}/${product.slug}`,
id: product.id,
title: product.name,
description: product.seo && product.seo.meta_description,
image_link: product.poster && product.poster.url,
price: product.price.toFixed() +'.00' + ' EUR' ,
availability: 'In Stock',
isDigital: product.isDigital,
brand: 'The brand',
})
)
return getServerSideSitemap(ctx, result)
}
export default function Site(){}
example of my returned XML:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>my-product-slug</link>
<id>9</id>
<title>Product title</title>
<description>Just some content</description>
<price>45.00 EUR</price>
<availability>In Stock</availability>
<isDigital>yes</isDigital>
<brand>The Brand</brand>
</url>
</urlset>
example of what Pinterest want:
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<item>
<g:id>4000086</g:id>
<title>Illuminating Makeup Mirror</title>
<description>A ring light mirror with 23 LED strip lights.</description>
<link>https://www.example.com/cat/illuminating-makeup-mirror</link>
<g:image_link>https://www.example.com/media/catalog/product/image.jpg</g:image_link>
<g:availability>In Stock</g:availability>
<g:price>14.99 GBP</g:price>
<g:price>0 GBP</g:price>
</item>
</channel>
</rss>