contentlayerdev / contentlayerdev/contentlayer

Define body as a field

未关闭
#92 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
meta: never-stale
主要语言
TypeScript
星标
3.5k
派生
192
PR 合并指标
30 天内没有已合并 PR

描述

Building on #91, `body` is the one field that feels a little too magical. It _just works_, which is great, but maybe not entirely obvious.

Putting this issue here to discuss separately.

One thought I had was that if we pursued #91, it'd justify this move more to me. In this case, the `fields` definition would contain **every property** in the document that is generated without a preceding underscore (generated/reserved).

While I like the magic, I also wouldn't mind being more explicit in my schema definition. We could remove the `bodyType` option and instead have something like this:

```js
fields: {
title: { type: 'string', required: true },
body: { type: 'mdx', source: 'body' }
}
```

This is just a first pass. TBH I don't like the shape of the API suggested above. Just something to get us thinking about this.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。