contentlayerdev / contentlayerdev/contentlayer

Add `Union` Field Type

Offen
#250 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
meta: never-stale needs-research topic: schema
Vorherrschende Sprache
TypeScript
Sterne
3.5k
Forks
192
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.