Function: directory()

View as Markdown
function directory(folder: string, { files }?: DirectoryOptions): Loader<FileInfo>;

Defined in: directory.ts:356

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

Returns

Loader<FileInfo>

Example

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