contentlayerdev / contentlayerdev/contentlayer

Add `Union` Field Type

Abierto
#250 3 comentarios 0 reacciones 0 asignados Ver en GitHub
meta: never-stale needs-research topic: schema
Lenguaje dominante
TypeScript
Estrellas
3.5k
Forks
192
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.