Function: defineCollection()
function defineCollection<TSchema extends StandardSchema, TOutput extends TransformOutput = TransformOutput, TFile extends FileInfo | undefined = FileInfo | undefined>(collection: Omit<CollectionConfig<Extract<TSchema, StandardSchema<object>>, TOutput, TFile>, "schema"> & {
schema: TSchema & ObjectSchema<TSchema>;
}): CollectionConfig<Extract<TSchema, StandardSchema<object>>, TOutput, TFile>;Defined in: index.ts:500
Defines a collection outside the config, eg in its own file, with transform typed from its schema.
Parameters
collection
Omit<CollectionConfig<Extract<TSchema, StandardSchema<object>>, TOutput, TFile>, "schema"> & { schema: TSchema & ObjectSchema<TSchema>; }
Returns
CollectionConfig<Extract<TSchema, StandardSchema<object>>, TOutput, TFile>
Example
export const posts = defineCollection({
loader: directory("content/posts"),
schema: z.strictObject({ title: z.string() }),
});
export default defineConfig({ collections: { posts } });