-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Feature(sitemap): named files chunking strategy #14471
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
base: main
Are you sure you want to change the base?
Conversation
Adds the ability to split sitemap generation into chunks based on customizable logic. This allows for better management of large sitemaps and improved performance. The new `chunks` option in the sitemap configuration allows users to define functions that categorize sitemap items into different chunks. Each chunk is then written to a separate sitemap file. This change introduces a new `writeSitemapChunk` function to handle the writing of individual sitemap chunks.
Adds a `chunks` option to the sitemap configuration schema. This allows users to define custom chunking strategies for generating sitemaps, providing flexibility in how the sitemap is split into multiple files.
The empty callback function in the `writeSitemap` function was causing unnecessary function calls. This commit fixes this by removing the empty callback.
This commit adds a test fixture to verify the sitemap chunking functionality. It includes a configuration file, dependencies, and several pages to simulate a real-world scenario.
Adds changeset to document the new sitemap chunking feature. This feature allows splitting sitemap generation into chunks based on customizable logic, improving management of large sitemaps and performance.
Feature(sitemap): named files chunking strategy
🦋 Changeset detectedLatest commit: c510a4c The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Feature/sitemap chunking strategy --fix lockfiles
The import order of `AstroConfig` has been moved to align with other imports, improving code readability and consistency. This change ensures that type imports are grouped together, making the codebase easier to maintain.
Simplify the chunk file test by using `path.resolve` and `includes` for better readability and maintainability. This change improves the test's clarity without altering its functionality.
The tests were failing intermittently because the `readXML` function was not properly resolving the file path. This commit updates the `readXML` function to use `fixture.readFile` to ensure that the file path is resolved correctly. Additionally, the `flatMapUrls` function is now async to ensure that the `readXML` function is awaited.
Is this a breaking change? |
no, it only add an optional chunk configuration in sitemap integration, i have added a testing file and fixture to sitemap integration module and all tests passed successfully |
|
||
for (const item of urlData) { | ||
// Await the asynchronous operation | ||
const collect = await Promise.resolve(cb(item)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need the Promise.resolve()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Promise.resolve()
call is indeed necessary in this case. The callback function cb
provided in the chunks
option can return either a direct SitemapItem
object or a Promise
that resolves to a SitemapItem
object. Promise.resolve()
ensures that the result is always a Promise, allowing for consistent handling of both synchronous and asynchronous results.
Co-authored-by: Matt Kane <[email protected]>
The previous changeset incorrectly marked the sitemap chunking feature as a major change. This commit corrects the changeset to reflect that it is a minor feature addition.
Changes
pnpm changeset
.New sitemap optional configuration for named sitemap files chunking strategy
Adds a chunks option to the sitemap configuration schema.
This allows users to define custom chunking strategies for
generating sitemaps, providing flexibility in how the sitemap
is split into multiple files.
Testing
Docs
yes, to add optional configurations for the chunks
@withastro/maintainers-docs for feedback!