contentlayerdev / contentlayerdev/contentlayer

Define body as a field

Đang mở
#92 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
meta: never-stale
Ngôn ngữ chính
TypeScript
Star
3.5k
Fork
192
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.