This commit is contained in:
Nate Moore 2021-06-28 12:17:24 -04:00
parent 2b48f10b77
commit 1a0425820d
2 changed files with 3 additions and 3 deletions

View file

@ -38,7 +38,7 @@ 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') {
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)}.`);
}
}

View file

@ -155,9 +155,9 @@ async function load(config: RuntimeConfig, rawPathname: string | undefined): Pro
let data: any[] = await loadData({ params: currentParams });
if (!data) throw new Error(`[createCollection] \`data()\` returned nothing (empty data)"`);
if (!Array.isArray(data)) data = [data]; // note: this is supposed to be a little friendlier to the user, but should we error out instead?
data = data.filter(entry => !entry.hasOwnProperty('published') || (entry.hasOwnProperty('published') && entry.published));
data = data.filter(entry => !entry.hasOwnProperty('published') || (entry.hasOwnProperty('published') && entry.published));
if (!buildOptions.draft && config.mode === "production") {
data = data.filter(entry => !entry.hasOwnProperty('draft') || (entry.hasOwnProperty('draft') && !entry.draft));
data = data.filter(entry => !entry.hasOwnProperty('draft') || (entry.hasOwnProperty('draft') && !entry.draft));
}
// handle RSS