# directory

Loads each Markdown file in a directory as an entry: its frontmatter is the metadata and the rest is the body.

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

```ts
function directory(folder: string, { files }?: DirectoryOptions): Loader<FileInfo>;
```

Defined in: [directory.ts:356](https://github.com/aayushbtw/tomekit/blob/main/packages/tomekit/src/directory.ts#L356)

Loads each Markdown file in a directory as an entry: its frontmatter is the metadata and the rest is the body.

The slug is the frontmatter's `slug`, or the file's path inside the directory without the extension, eg `guides/setup`.

## Parameters

### folder

`string`

Relative to the project root, eg `content/posts`.

### { files }?

[`DirectoryOptions`](https://tomekit.aayush.cv/api-tomekit/interfaces/DirectoryOptions/index.md)

## Returns

[`Loader`](https://tomekit.aayush.cv/api-tomekit/interfaces/Loader/index.md)`<`[`FileInfo`](https://tomekit.aayush.cv/api-tomekit/interfaces/FileInfo/index.md)`>`

## Example

```ts
posts: {
  loader: directory("content/posts", { files: ["**\/*.md", "!drafts/**"] }),
  schema: z.strictObject({ title: z.string() }),
}
```
