contentlayerdev / contentlayerdev/contentlayer

Add `Union` Field Type

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

説明

Basically, allow me to define a union of types that a field can be.

Simple example would be `string | string[]`. Config proposal:

```typescript
// ...
author: {
type: `union`,
of: [
{
type: `string`
},
{
type: `list`,
of: {
type: `string`
}
}
]
},
```

This would permit the following frontmatter:

```yaml
author: Foo Bar
# or
author:
- Foo Bar
- Baz Qux
```

If this is already possible with the existing field types, please add examples to the documentation which demonstrate how to do this, as it's not readily apparent how this can be done.

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

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

評価

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

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

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