References
The s.keyOf() schema type creates a reference to keys from another Val module that is defined using s.record(). This enables safe references between your content, ensuring that links and references always point to existing content.
Note: For referencing routes in page routers, use s.route() instead. See the Page Router guide for more information.
Setting up referenceable content
In order to refer to content using keyOf, you must first have a s.record to which you want to refer.
In the example below, we have defined a module of all authors by email.
Refering to content using keyOf
When you have a record of keys that you want to refer to, use s.keyOf. This will make it possible for content editors to select from a list of possible options, the keys of the record. It will also make it possible for Val to validate the reference.
Recursive keyOf
When using keyOf, you might end up in a situation where you have mutually recursive schemas. A consequence of this is that TypeScript will no longer be able to infer the types of the modules that are mutually recursive.
To avoid this, you can use the "getter syntax" on all keyOf related types.
By using the the "getter syntax" you are now able to use the linkButton in the blogs / support article pages.