0.2.8
ℹ️ [TLDR] 0.2.8 improves list fields, field validations and error handling, type safety, and monorepo support.
✨ Improved Monorepo Support
When accessing documents outside the directory that contains contentlayer.config.ts
, you can define contentDirPath
using relative values. For example, consider a repo with the following directory structure:
.
├── docs [NextJS docs site]
└── components/
├── component-1/
│ └── README.md
├── component-2/
│ └── README.md
└── component-3/
└── README.md
You can define define contentDirPath
in docs/contentlayer.config.ts
as ..
, allowing access to markdown files in the components
directory.
export default makeSource({
// ...
contentDirPath: ".."
})
You can then run contentlayer build
directly from the project subdirectory (docs
in this example). See #295 for more details.
Avoiding INIT_CWD
This release also brings better support for various monorepo tooling — Lerna, Turborepo, NPM workspaces, etc. See #104 for details.
More list
Field Types
#87 identified an issue with validating list
field values. These validations have been improved, along with additional types within list fields. For example, previously, numbers were not supported, but are now available.
Type Safety for date
Values
Being that there is no concept of a date type in JSON, Contentlayer stores date values as strings. Previously, these values were assigned a string
type by Contentlayer's automatically-exported type definitions. Now the type is called IsoDateTimeString
. It is an alias to string
, but will make it easier to introduce type-safety for date fields in your projects.
export type Page = {
// ...
date: IsoDateTimeString
}
Other Improvements
- When encountering issues with singleton documents, Contentlayer will fail gracefully, with improved error messaging.
- Upgraded dependencies.