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

[question] How to allow empty sitemap? #421

Open
Sammaye opened this issue May 12, 2024 · 3 comments
Open

[question] How to allow empty sitemap? #421

Sammaye opened this issue May 12, 2024 · 3 comments

Comments

@Sammaye
Copy link

Sammaye commented May 12, 2024

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?

@huntharo
Copy link
Contributor

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:

  1. Reading a sitemap, deleting all the items and writing it back is refusing to write an empty sitemap
  2. Initializing a sitemap, writing no items, then closing it, is hanging or not writing any file
  3. Something else

@Sammaye
Copy link
Author

Sammaye commented May 19, 2024

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

@huntharo
Copy link
Contributor

huntharo commented May 20, 2024

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 parallel (streamToPromise is not actually used at all internally except in tests - but there is similar "throw on empty" behavior elsewhere).

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

2 participants