contentlayerdev / contentlayerdev/contentlayer

Enable specifying list type in computed fields

オープン
#277 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
improvement meta: never-stale topic: schema
主要言語
TypeScript
スター
3.5k
フォーク
192
PR マージ指標
30日以内にマージされた PR はありません

説明

As far as I can tell, it isn't possible to specify the `of` type of lists in computed fields the way that you can in non-computed fields. Thus, this is possible:

```typescript
fields: {
tags: {
type: "list",
of: { type: "string" },
default: []
}
}
```

But this is not:

```typescript
computedFields: {
segments: {
type: "list",
of: { type: "string" },
resolve: (doc) => { ... }
}
}
```

Instead, you can only specify an untyped list, and in the generated output you end up with this:

```typescript
segments: list
```

But this raw `list` type isn't defined!

There may be reasons to explicitly disallow typed lists in computed fields, and if so I'd be curious why! Otherwise, this feels like an oversight to me.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。