diff --git a/src/build.ts b/src/build.ts index 9f9f8f3ea..8310b1179 100644 --- a/src/build.ts +++ b/src/build.ts @@ -186,7 +186,7 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> { const filepath = new URL(`file://${pathname}`); const pageType = getPageType(filepath); - const pageOptions: PageBuildOptions = { astroRoot, dist, filepath, runtime, sitemap: astroConfig.sitemap, statics }; + const pageOptions: PageBuildOptions = { astroRoot, dist, filepath, runtime, sitemap: astroConfig.buildOptions.sitemap, statics }; if (pageType === 'collection') { const { canonicalURLs } = await buildCollectionPage(pageOptions); builtURLs.push(...canonicalURLs); @@ -239,7 +239,7 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> { } // build sitemap - if (astroConfig.sitemap && astroConfig.site) { + if (astroConfig.buildOptions.sitemap && astroConfig.site) { const sitemap = generateSitemap( builtURLs.map((url) => ({ canonicalURL: new URL( @@ -249,7 +249,7 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> { })) ); await writeFile(new URL('./sitemap.xml', dist), sitemap, 'utf8'); - } else if (astroConfig.sitemap) { + } else if (astroConfig.buildOptions.sitemap) { info(logging, 'tip', `Set your "site" in astro.config.mjs to generate a sitemap.xml`); } diff --git a/src/config.ts b/src/config.ts index af618a27f..5b77a3402 100644 --- a/src/config.ts +++ b/src/config.ts @@ -25,7 +25,7 @@ function validateConfig(config: any): void { } } - if(config.devOptions?.port !== 'number') { + if(typeof config.devOptions?.port !== 'number') { throw new Error(`[astro config] devOptions.port: Expected number, received ${type(config.devOptions?.port)}`) } } @@ -40,7 +40,8 @@ function configDefaults(userConfig?: any): any { if (!config.public) config.public = './public'; if (!config.devOptions) config.devOptions = {}; if (!config.devOptions.port) config.devOptions.port = 3000; - if (typeof config.sitemap === 'undefined') config.sitemap = true; + if (!config.buildOptions) config.buildOptions = {}; + if (typeof config.buildOptions.sitemap === 'undefined') config.buildOptions.sitemap = true; return config; }