Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally allow runtime logic to prevent dynamic sitemap creation from defineSitemapEventHandler #314

Open
harlan-zw opened this issue Jul 14, 2024 · 0 comments

Comments

@harlan-zw
Copy link
Collaborator

(cloned from harlan-zw/nuxt-seo#237)

Clear and concise description of the problem

  • I have a multi-tenant Nuxt app.
  • Each tenant can define both public and private Page and Product routes (i.e. the data is fetched at runtime), and I utilize multiple sitemaps respectively for each type of route.

Using Product routes as an example, I would like to do a check at runtime inside the defineSitemapEventHandler for the Products sitemap if each product is public or private.

  1. If the product route should be public, I add to the sitemap.
  2. If the product route is private, it is excluded from the sitemap.

After parsing all of the product routes, if there are zero product routes added to the array, I would like to prevent the products_sitemap.xml from being created rather than just returning an empty array.

Suggested solution

Ideally, returning an empty array (or undefined) from defineSitemapEventHandler should prevent the sitemap from being created, and in a multiple sitemap app, it should prevent this sitemap from being linked from the sitemap_index.xml

Alternative

Returning an empty array from defineSitemapEventHandler works for not indexing the routes, but you are left with an empty sitemap.

Additional context

I don't want to disable indexing for the whole site, just for individual sitemaps, e.g. the pages sitemap should exist, products sitemap should be empty/not exist if the array of routes is empty, but this cannot be determined until in the event handler at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant