diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index de2449104..a49dd495b 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -243,7 +243,7 @@ export interface AstroUserConfig { * } * ``` */ - sitemapFilter?: (page: string) => boolean + sitemapFilter?: (page: string) => boolean; /** * @docs diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 816abd8ba..623450592 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -150,7 +150,10 @@ class AstroBuilder { if (this.config.buildOptions.sitemap && this.config.buildOptions.site) { timer.sitemapStart = performance.now(); const sitemapFilter = this.config.buildOptions.sitemapFilter ? (this.config.buildOptions.sitemapFilter as (page: string) => boolean) : undefined; - const sitemap = generateSitemap(pageNames.map((pageName) => new URL(pageName, this.config.buildOptions.site).href), sitemapFilter); + const sitemap = generateSitemap( + pageNames.map((pageName) => new URL(pageName, this.config.buildOptions.site).href), + sitemapFilter + ); const sitemapPath = new URL('./sitemap.xml', this.config.dist); await fs.promises.mkdir(new URL('./', sitemapPath), { recursive: true }); await fs.promises.writeFile(sitemapPath, sitemap, 'utf8'); diff --git a/packages/astro/src/core/render/sitemap.ts b/packages/astro/src/core/render/sitemap.ts index 2956d72ac..b7191e23e 100644 --- a/packages/astro/src/core/render/sitemap.ts +++ b/packages/astro/src/core/render/sitemap.ts @@ -1,4 +1,3 @@ - const STATUS_CODE_PAGE_REGEXP = /\/[0-9]{3}\/?$/; /** Construct sitemap.xml given a set of URLs */ @@ -11,7 +10,7 @@ export function generateSitemap(pages: string[], filter?: (page: string) => bool let urls = [...pages].filter((url) => !STATUS_CODE_PAGE_REGEXP.test(url)); if (filter) { - urls = urls.filter(url => filter(url)); + urls = urls.filter((url) => filter(url)); } urls.sort((a, b) => a.localeCompare(b, 'en', { numeric: true })); // sort alphabetically so sitemap is same each time