prestaconcept / PrestaSitemapBundle

A symfony bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.
MIT License
347 stars 100 forks source link

Allow to add custom URLs to sitemap index without populating section #339

Closed norkunas closed 3 months ago

norkunas commented 4 months ago

Description
We have a nextjs app for landing pages in front of our internal app, previously we managed sitemaps in the internal app with this bundle, but now that nextjs app is multilingual, it exposes it's sitemap and then we proxy it. But we have to fake add at least one URL so it is added to the sitemap root.

Example
Not sure what's the best option here, maybe new event like SitemapRootCreatedEvent and then in Presta\SitemapBundle\Service\AbstractGenerator::getRoot dispatch it?

yann-eugone commented 3 months ago

I'm sorry, but I don't understand neither the issue you are facing nor the solution you are pointing Is there any chance you can try to reformulate?

norkunas commented 3 months ago

All right, in simple words: how to add something to sitemap index without using SitemapPopulateEvent ?

yann-eugone commented 3 months ago

In the context of? generating the sitemap? dumping the sitemap?

norkunas commented 3 months ago

dumping :)

yann-eugone commented 3 months ago

I don't understand why you cannot rely on SitemapPopulateEvent, but here's my 2 cent: Add a listener to console.command, with a dependency on \Presta\SitemapBundle\Service\DumperInterface and call \Presta\SitemapBundle\Service\UrlContainerInterface::addUrl on it

norkunas commented 3 months ago

I don't understand why you cannot rely on SitemapPopulateEvent

if it's possible to add a different sitemap link without adding an URL for that section, then I could if you'd share some example :thinking:

yann-eugone commented 3 months ago

OK, I think I understand better your need You need a sitemap index file, pointing to sitemap (sections), but these sitemaps will not contain any url (the associated file will not even exist)

Am I correct ?

norkunas commented 3 months ago

Yes something like that. We use that event for most of our sitemaps, but our microservice has it's own sitemap, so I just need to add a pointer that it exists :)

yann-eugone commented 3 months ago

I don't think it is a good idea to add to this bundle the ability to have empty sitemap sections The system heavily rely on the presence of URLs to be generated

I suggest you find another solution for your sitemap index to be generated Because you are not going to add any URL to this sitemap, I suggest you just generate the sitemap index using a twig template (or anything else)

norkunas commented 3 months ago

So that means this bundle can't be friendly to any other sitemap generators? :) because the current workaround is to add random url to that section, so it is at least exposed through sitemap index

yann-eugone commented 3 months ago

There is nothing to do with "being friendly", please stay nice

I don't say you are doing things wrong or something alike But thing is the thing you ask is going against the DNA of the library So, to me it is a no go

norkunas commented 3 months ago

Okay, then will use current workaround, thanks for your time :pray: