[ci] format
This commit is contained in:
parent
10843aba63
commit
7b18d4c226
3 changed files with 6 additions and 4 deletions
|
@ -243,7 +243,7 @@ export interface AstroUserConfig {
|
|||
* }
|
||||
* ```
|
||||
*/
|
||||
sitemapFilter?: (page: string) => boolean
|
||||
sitemapFilter?: (page: string) => boolean;
|
||||
|
||||
/**
|
||||
* @docs
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue