# defineCollection

Defines a collection outside the config, eg in its own file, with transform typed from its schema.

> Every page: https://tomekit.aayush.cv/llms.txt

```ts
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](https://github.com/aayushbtw/tomekit/blob/main/packages/tomekit/src/index.ts#L500)

Defines a collection outside the config, eg in its own file, with `transform` typed from its schema.

## Parameters

### collection

`Omit<`[`CollectionConfig`](https://tomekit.aayush.cv/api-tomekit/interfaces/CollectionConfig/index.md)`<Extract<TSchema,` [`StandardSchema`](https://tomekit.aayush.cv/api-tomekit/interfaces/StandardSchema/index.md)`<object>>, TOutput, TFile>, "schema"> & { schema: TSchema & ObjectSchema<TSchema>; }`

## Returns

[`CollectionConfig`](https://tomekit.aayush.cv/api-tomekit/interfaces/CollectionConfig/index.md)`<Extract<TSchema,` [`StandardSchema`](https://tomekit.aayush.cv/api-tomekit/interfaces/StandardSchema/index.md)`<object>>, TOutput, TFile>`

## Example

```ts
export const posts = defineCollection({
  loader: directory("content/posts"),
  schema: z.strictObject({ title: z.string() }),
});

export default defineConfig({ collections: { posts } });
```
