contentlayerdev / contentlayerdev/contentlayer

Computed fields in nested types

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

描述

I'd like to be able to define computed fields in nested types:

```ts
export const Item = defineNestedType(() => ({
name: "Item",
fields: {
name: { type: "string", required: true },
},
computedFields: {
slug: {
type: "string",
resolve: ({ name }) => slugify(name),
},
},
}))
```

It seems that computed fields are currently only available in document types though. I think supporting computed fields also in nested types would be a great enhancement of this awesome project.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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