diff options
author | 2023-07-14 19:32:59 +0000 | |
---|---|---|
committer | 2023-07-14 19:32:59 +0000 | |
commit | 4f9032be7c71247ca0051385e4b76cabe69667e7 (patch) | |
tree | d106ec2d039a82449067f40c12420ddb7894caca | |
parent | c258492b7218cc7e5b7be38f48ec1bb1296292d5 (diff) | |
download | astro-4f9032be7c71247ca0051385e4b76cabe69667e7.tar.gz astro-4f9032be7c71247ca0051385e4b76cabe69667e7.tar.zst astro-4f9032be7c71247ca0051385e4b76cabe69667e7.zip |
[ci] format
-rw-r--r-- | packages/integrations/sitemap/src/index.ts | 50 | ||||
-rw-r--r-- | packages/integrations/sitemap/test/staticPaths.test.js | 4 |
2 files changed, 28 insertions, 26 deletions
diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index ffa593a92..0d52095c6 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -22,24 +22,24 @@ export type LinkItem = LinkItemBase; export type SitemapOptions = | { - filter?(page: string): boolean; - customPages?: string[]; - - i18n?: { - defaultLocale: string; - locales: Record<string, string>; - }; - // number of entries per sitemap file - entryLimit?: number; - - // sitemap specific - changefreq?: ChangeFreq; - lastmod?: Date; - priority?: number; - - // called for each sitemap item just before to save them on disk, sync or async - serialize?(item: SitemapItem): SitemapItem | Promise<SitemapItem | undefined> | undefined; - } + filter?(page: string): boolean; + customPages?: string[]; + + i18n?: { + defaultLocale: string; + locales: Record<string, string>; + }; + // number of entries per sitemap file + entryLimit?: number; + + // sitemap specific + changefreq?: ChangeFreq; + lastmod?: Date; + priority?: number; + + // called for each sitemap item just before to save them on disk, sync or async + serialize?(item: SitemapItem): SitemapItem | Promise<SitemapItem | undefined> | undefined; + } | undefined; function formatConfigErrorMessage(err: ZodError) { @@ -86,12 +86,14 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { return; } - let pageUrls = pages.filter((p) => !STATUS_CODE_PAGES.has('/' + p.pathname.slice(0, -1))).map((p) => { - if (p.pathname !== '' && !finalSiteUrl.pathname.endsWith('/')) - finalSiteUrl.pathname += '/'; - const path = finalSiteUrl.pathname + p.pathname; - return new URL(path, finalSiteUrl).href; - }); + let pageUrls = pages + .filter((p) => !STATUS_CODE_PAGES.has('/' + p.pathname.slice(0, -1))) + .map((p) => { + if (p.pathname !== '' && !finalSiteUrl.pathname.endsWith('/')) + finalSiteUrl.pathname += '/'; + const path = finalSiteUrl.pathname + p.pathname; + return new URL(path, finalSiteUrl).href; + }); let routeUrls = routes.reduce<string[]>((urls, r) => { /** diff --git a/packages/integrations/sitemap/test/staticPaths.test.js b/packages/integrations/sitemap/test/staticPaths.test.js index 6fddbb193..3365ff1e8 100644 --- a/packages/integrations/sitemap/test/staticPaths.test.js +++ b/packages/integrations/sitemap/test/staticPaths.test.js @@ -14,7 +14,7 @@ describe('getStaticPaths support', () => { await fixture.build(); const data = await readXML(fixture.readFile('/sitemap-0.xml')); - urls = data.urlset.url.map(url => url.loc[0]); + urls = data.urlset.url.map((url) => url.loc[0]); }); it('requires zero config for getStaticPaths', async () => { @@ -28,5 +28,5 @@ describe('getStaticPaths support', () => { it('includes numerical pages', () => { expect(urls).to.include('http://example.com/123/'); - }) + }); }); |