contentlayerdev / contentlayerdev/contentlayer

Add `Union` Field Type

Ouverte
#250 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
meta: never-stale needs-research topic: schema
Langage dominant
TypeScript
Étoiles
3.5k
Forks
192
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.