You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature(sitemap): named files chunking strategy (#14471)
* feat(sitemap): add chunking strategy for sitemaps
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.
* feat(sitemap): add chunks option to sitemap config
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.
* feat(sitemap): add sitemap chunk writing functionality
* fix(sitemap): fix empty callback in writeSitemap
The empty callback function in the `writeSitemap` function was
causing unnecessary function calls. This commit fixes this by
removing the empty callback.
* feat(sitemap): add test fixture for sitemap chunking
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.
* test(sitemap): add test for sitemap chunking with files
* feat(sitemap): add changeset for sitemap chunking
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.
* build: update dependencies and add astro
* chore: remove unused astro dependency
* chore: remove unused entries from lockfile
* refactor(sitemap): improve import ordering and formatting
* refactor(sitemap): improve import ordering
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.
* refactor(sitemap): improve import ordering
* refactor(sitemap): improve import ordering
* refactor(sitemap): improve import ordering
* refactor(sitemap): improve chunk file test readability
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.
* test(sitemap): fix flaky chunk file tests
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.
* refactor(sitemap): improve import ordering
* Update .changeset/floppy-times-grab.md
Co-authored-by: Matt Kane <m@mk.gg>
* chore(sitemap): update changeset to minor
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.
* feat(sitemap): add chunking support for sitemap generation
* fix: attempt to fix lockfile
* fix: conflict
* fix: lockfile
---------
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com>
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.
6
+
7
+
```
8
+
integrations: [
9
+
sitemap({
10
+
serialize(item) { th
11
+
return item
12
+
},
13
+
chunks: { // this property will be treated last on the configuration
14
+
'blog': (item) => { // will produce a sitemap file with `blog` name (sitemap-blog-0.xml)
15
+
if (/blog/.test(item.url)) { // filter path that will be included in this specific sitemap file
16
+
item.changefreq = 'weekly';
17
+
item.lastmod = new Date();
18
+
item.priority = 0.9; // define specific properties for this filtered path
19
+
return item;
20
+
}
21
+
},
22
+
'glossary': (item) => {
23
+
if (/glossary/.test(item.url)) {
24
+
item.changefreq = 'weekly';
25
+
item.lastmod = new Date();
26
+
item.priority = 0.7;
27
+
return item;
28
+
}
29
+
}
30
+
31
+
// the rest of the path will be stored in `sitemap-pages.0.xml`
0 commit comments