Skip to content

Commit

Permalink
Fix getCollection when collection is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOtterlord committed Sep 22, 2023
1 parent de7a7fb commit b679391
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions packages/astro/src/content/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { MarkdownHeading } from '@astrojs/markdown-remark';
import { ZodIssueCode, string as zodString } from 'zod';
import type { AstroIntegration } from '../@types/astro.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { prependForwardSlash } from '../core/path.js';
import {
Expand Down Expand Up @@ -56,7 +55,8 @@ export function createGetCollection({
} else if (collection in dataCollectionToEntryMap) {
type = 'data';
} else {
return warnOfEmptyCollection(collection);
console.warn(`The collection **${collection}** does not exist or is empty. Ensure a collection directory with this name exists.`);
return [];
}
const lazyImports = Object.values(
type === 'content'
Expand Down Expand Up @@ -390,16 +390,3 @@ type PropagatedAssetsModule = {
function isPropagatedAssetsModule(module: any): module is PropagatedAssetsModule {
return typeof module === 'object' && module != null && '__astroPropagation' in module;
}

function warnOfEmptyCollection(collection: string): AstroIntegration {
return {
name: 'astro-collection',
hooks: {
'astro:server:start': ({ logger }) => {
logger.warn(
`The collection **${collection}** does not exist or is empty. Ensure a collection directory with this name exists.`
);
},
},
};
}

0 comments on commit b679391

Please sign in to comment.