-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Labels
featureNew feature or requestNew feature or request
Description
Given the following config:
const Category = defineDocumentType(() => ({
name: 'Category',
filePathPattern: 'categories/*.md',
bodyType: 'none',
fields: {
title: { type: 'string', required: true },
},
}))
const Doc = defineDocumentType(() => ({
name: 'Doc',
filePathPattern: '**/*.mdx',
bodyType: 'mdx',
fields: {
title: { type: 'string', required: true },
category: { type: 'reference', of: Category }
},
}))
export default makeSource({
contentDirPath: 'content',
documentTypes: [Doc, Category],
})
And the following content files:
content/categories/a.md
---
title: My First Category
---
content/docs/index.mdx
---
title: Home Page
category: categories/a.md
---
The output document would have the following:
{
"title": "Home Page",
"category": "categories/a.md",
// ...
}
It would be nice to (optionally) embed the category data directly in the output document. Otherwise, I have to defer that logic to my application. Being that it's data manipulation, it seems right that Contentlayer would handle this.
I'd rather see the output like this:
{
"title": "Home Page",
"category": {
"title": "My First Category"
},
// ...
}
schickling
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request