contentlayerdev / contentlayerdev/contentlayer

Exploring alternative approaches to lists

Open
#88 0 comments 4 reactions 0 assignees View on GitHub
feature pkg/source-files
Dominant language
TypeScript
Stars
3.5k
Forks
192
PR merge metrics
No merged PRs in 30d

Description

The way lists work have been tripping me up in writing the documentation. I'm documenting how they behave today, but they feel a little too magical. For example, there is different behavior based on the type of the `of` option.

Perhaps any field could be a list. I could do something like this:

```js
{
fields: {
// ...
tags: { type: 'reference', of: Tag, list: true }
}
}
```

If we were to do that, it would also be interesting to consider if any field could then be polymorphic. For example, what if I wanted a list of strings or numbers?

```js
{
fields: {
// ...
someListField: { type: ['string', 'number'], list: true }
}
}
```

This polymorphic field type could be interesting to consider outside this context, too. Perhaps any field (not just a list) could be one of multiple types and still be valid.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.