d3xter-dev / sitemap-module-nuxt-3

Sitemap Module for Nuxt 3
https://sitemap.nuxtjs.org
MIT License
63 stars 12 forks source link

“Generating sitemaps” message printed numerous times, sitemap incomplete #7

Closed Anoesj closed 1 year ago

Anoesj commented 2 years ago

When running pnpm nuxt generate, the following message is repeated for every generated html file

ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml

Let me give an example of a sitemap.xml and the pnpm nuxt generate output in a very common Nuxt 3 setup.

Contents of pages/ directory:

Output of pnpm nuxt generate:

ℹ Client built in 4779ms
ℹ Building server...
✔ Server built in 1329ms
✔ Generated public .output/public
ℹ Initializing prerenderer
ℹ Prerendering 2 initial routes with crawler
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ /users (333ms) 
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ / (46ms) 
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ /users/1 (49ms) 
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ /about (49ms) 
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ /topics (99ms) 
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ /topics/environment (48ms) 
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ /topics/environment/nitrogen-crisis (42ms) 
ℹ Generating sitemaps
✔ Generated /../.output/public/sitemap.xml
  ├─ /topics/politics (34ms) 
✔ You can now deploy .output/public to any static hosting!

Firstly, this output is confusing, because it feels like this output suggests that the sitemap.xml file is overwritten many times.

Secondly, one would think that all the routes that were prerendered by Nuxt would appear in the generated sitemap.xml, but only the static/non-dynamic routes were actually added to sitemap.xml, namely:

Could you reply to both of these issues and clear up if this is the expected behavior?

Thank you!

d3xter-dev commented 1 year ago

I tried a few things, the current version fixes the spamming of "Generating sitemaps", it now only generates it once.

EDIT: Will release a new version today which will add the pre-rendered routes.

Anoesj commented 1 year ago

Sounds great, thanks so much!

d3xter-dev commented 1 year ago

Just released a new Version

Anoesj commented 1 year ago

Works great, thank you! 🥳