Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored and astrobot-houston committed Jul 14, 2023
1 parent c258492 commit 4f9032b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
50 changes: 26 additions & 24 deletions packages/integrations/sitemap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) => {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/sitemap/test/staticPaths.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -28,5 +28,5 @@ describe('getStaticPaths support', () => {

it('includes numerical pages', () => {
expect(urls).to.include('http://example.com/123/');
})
});
});

0 comments on commit 4f9032b

Please sign in to comment.