adds default value for buildOptions.draft
This commit is contained in:
parent
7063c04dec
commit
61ec2c54c0
2 changed files with 6 additions and 0 deletions
|
@ -26,6 +26,8 @@ export interface AstroConfig {
|
|||
markdownOptions?: Partial<AstroMarkdownOptions>;
|
||||
/** Options specific to `astro build` */
|
||||
buildOptions: {
|
||||
/** should draft documents be ignored **/
|
||||
draft: boolean;
|
||||
/** Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs. */
|
||||
site?: string;
|
||||
/** Generate sitemap (set to "false" to disable) */
|
||||
|
|
|
@ -38,6 +38,9 @@ function validateConfig(config: any): void {
|
|||
throw new Error('[config] buildOptions.site must be a valid URL');
|
||||
}
|
||||
}
|
||||
if(config.buildOptions.drafts !== undefined && typeof config.buildOptions.drafts !== 'boolean') {
|
||||
throw new Error(`[config] buildOptions.drafts: ${JSON.stringify(config.buildOptions.drafts)}\n Expected boolean, received ${type(config.buildOptions.drafts)}.`);
|
||||
}
|
||||
}
|
||||
|
||||
// devOptions
|
||||
|
@ -63,6 +66,7 @@ function configDefaults(userConfig?: any): any {
|
|||
if (!config.buildOptions) config.buildOptions = {};
|
||||
if (!config.markdownOptions) config.markdownOptions = {};
|
||||
if (typeof config.buildOptions.sitemap === 'undefined') config.buildOptions.sitemap = true;
|
||||
if (typeof config.buildOptions.draft === 'undefined') config.buildOptions.draft = true;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue