[ci] format
This commit is contained in:
parent
c258492b72
commit
4f9032be7c
2 changed files with 25 additions and 23 deletions
|
@ -22,24 +22,24 @@ export type LinkItem = LinkItemBase;
|
||||||
|
|
||||||
export type SitemapOptions =
|
export type SitemapOptions =
|
||||||
| {
|
| {
|
||||||
filter?(page: string): boolean;
|
filter?(page: string): boolean;
|
||||||
customPages?: string[];
|
customPages?: string[];
|
||||||
|
|
||||||
i18n?: {
|
i18n?: {
|
||||||
defaultLocale: string;
|
defaultLocale: string;
|
||||||
locales: Record<string, string>;
|
locales: Record<string, string>;
|
||||||
};
|
};
|
||||||
// number of entries per sitemap file
|
// number of entries per sitemap file
|
||||||
entryLimit?: number;
|
entryLimit?: number;
|
||||||
|
|
||||||
// sitemap specific
|
// sitemap specific
|
||||||
changefreq?: ChangeFreq;
|
changefreq?: ChangeFreq;
|
||||||
lastmod?: Date;
|
lastmod?: Date;
|
||||||
priority?: number;
|
priority?: number;
|
||||||
|
|
||||||
// called for each sitemap item just before to save them on disk, sync or async
|
// called for each sitemap item just before to save them on disk, sync or async
|
||||||
serialize?(item: SitemapItem): SitemapItem | Promise<SitemapItem | undefined> | undefined;
|
serialize?(item: SitemapItem): SitemapItem | Promise<SitemapItem | undefined> | undefined;
|
||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
|
|
||||||
function formatConfigErrorMessage(err: ZodError) {
|
function formatConfigErrorMessage(err: ZodError) {
|
||||||
|
@ -86,12 +86,14 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pageUrls = pages.filter((p) => !STATUS_CODE_PAGES.has('/' + p.pathname.slice(0, -1))).map((p) => {
|
let pageUrls = pages
|
||||||
if (p.pathname !== '' && !finalSiteUrl.pathname.endsWith('/'))
|
.filter((p) => !STATUS_CODE_PAGES.has('/' + p.pathname.slice(0, -1)))
|
||||||
finalSiteUrl.pathname += '/';
|
.map((p) => {
|
||||||
const path = finalSiteUrl.pathname + p.pathname;
|
if (p.pathname !== '' && !finalSiteUrl.pathname.endsWith('/'))
|
||||||
return new URL(path, finalSiteUrl).href;
|
finalSiteUrl.pathname += '/';
|
||||||
});
|
const path = finalSiteUrl.pathname + p.pathname;
|
||||||
|
return new URL(path, finalSiteUrl).href;
|
||||||
|
});
|
||||||
|
|
||||||
let routeUrls = routes.reduce<string[]>((urls, r) => {
|
let routeUrls = routes.reduce<string[]>((urls, r) => {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('getStaticPaths support', () => {
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
|
|
||||||
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
|
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 () => {
|
it('requires zero config for getStaticPaths', async () => {
|
||||||
|
@ -28,5 +28,5 @@ describe('getStaticPaths support', () => {
|
||||||
|
|
||||||
it('includes numerical pages', () => {
|
it('includes numerical pages', () => {
|
||||||
expect(urls).to.include('http://example.com/123/');
|
expect(urls).to.include('http://example.com/123/');
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue