[question] How to allow empty sitemap?
Sammaye opened this issue · 3 comments
I know my sitemap is empty I have done stuff to make it empty but this repo keeps giving me an error that it's empty and refuses to update the sitemap, is there a way I can bypass this error?
Can you make simple self-contained example or add a test that shows the issue you are encountering?
It's hard to know if you are saying:
- Reading a sitemap, deleting all the items and writing it back is refusing to write an empty sitemap
- Initializing a sitemap, writing no items, then closing it, is hanging or not writing any file
- Something else
Well, it is quite simple, it just triggers this https://github.com/ekalinin/sitemap.js/blob/master/lib/sitemap-stream.ts#L135 when there are no sitemap items.
I have solved this atm but adding a sitemap item of the websites homepage, this allows me to "empty" the sitemap
Well, it is quite simple, it just triggers this https://github.com/ekalinin/sitemap.js/blob/master/lib/sitemap-stream.ts#L135 when there are no sitemap items.
I have solved this atm but adding a sitemap item of the websites homepage, this allows me to "empty" the sitemap
Thanks!
There are a few issues in the repo related to this behavior and there are some annoying issues that it causes. I'm going to see about changing it to no longer throw and/or to not use the (streamToPromise
method at all, since it also keeps a copy of all written data in memory until the stream is finished, which is inefficient when writing many sitemaps in parallelstreamToPromise
is not actually used at all internally except in tests - but there is similar "throw on empty" behavior elsewhere).