nuxt-community / sitemap-module

Sitemap Module for Nuxt 2
https://sitemap.nuxtjs.org
MIT License
685 stars 129 forks source link

Dynamicly variable dynamic sitemaps #267

Open ibrahimBeladi opened 1 year ago

ibrahimBeladi commented 1 year ago

I am trying to generate various sitemaps based on various api end points. Let's assume having 2 end points, one for users and the other for events. Each with 2000+ record. I want to generate sitemaps where each is having upto 1000 records, and in the end, include these dynamically dynamic sitemaps, with another statically made sitemap (let call it public.xml) and include them all in the main sitemap (let's call it sitemap.xml)

public.xml would be like

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <loc>DOMAIN</loc>
    </url>
    ....
    <url>
        <loc>DOMAIN/about</loc>
    </url>
</urlset>

sitemap.xml would be like:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>DOMAIN/sitemaps/users.xml</loc>
    </sitemap>
    <sitemap>
        <loc>DOMAIN/sitemaps/users_2.xml</loc>
    </sitemap>
    ....
    <sitemap>
        <loc>DOMAIN/sitemaps/events.xml</loc>
    </sitemap>
    <sitemap>
        <loc>DOMAIN/sitemaps/events_2.xml</loc>
    </sitemap>
    ....
    <sitemap>
        <loc>DOMAIN/sitemaps/public.xml</loc>
    </sitemap>
</sitemapindex>

I tried various combinations, but nothing seems to work 100% deterministically, one time it works, another time it fails. It takes long time to test this out as I need to test it with more than one model with each having more than one page.