Collections
Collection of content data for your app
Define Collections
Define a collection to parse a certain set of files.
Prop | Type | Default |
---|---|---|
dir | string | string[] | - |
files | string[] | - |
schema | Schema | ((ctx: TransformContext) => Schema) | - |
type | Type | - |
transform | (entry: CollectionEntry<Type, output<Schema>>, globalConfig?: GlobalConfig | undefined) => Output | Promise<Output> | - |
mdxOptions | Type extends "doc" ? MDXOptions : never | - |
Options
dir
Directories to scan input files.
Schema
The Zod schema to validate file data (frontmatter on doc
type, content on meta
type).
You can add additional properties to the output. Note that the validation is done by build time, hence the output must be serializable.
You can also pass a function and receives the transform context.
Type
The accepted type of collection.
Type | Description |
---|---|
meta | JSON/YAML File |
doc | Markdown/MDX Documents |
MDX Options
You can also customise MDX options from collections.
Notice that passing mdxOptions
to collection overrides all defaults from global config.
We use getDefaultMDXOptions
to apply default MDX options, it accepts the Default MDX Options.
For full control over MDX options, you can pass MDX options without getDefaultMDXOptions
, which means no defaults will be applied (except the ones from MDX.js).
This API only available on doc
type.
Transform
A function to perform runtime transformation on collection entries.
See Transform.
Define Docs
You can use defineDocs
to define the required collections to work with Adalt.
It offers the same API as defineCollections
.
The docs
and meta
are collections on their own.
You can pass collection options to them as shown above.
Extend schema
You can extend the default Zod schema of docs
and meta
.
Last updated on