-
Currently in a NetlifyCMS project, I'm defining the CMS UI via typescript and then making the content available as imports via contentlayer, which generates types for all my generated content. Problem with this approach is that I end up defining the schema twice:
Will KeyStatic do this for me? edit: to clarify Here's a basic level example https://github.com/officialrajdeepsingh/contentLayerNetlifycms/blob/main/contentlayer.config.ts
I'm hoping that I wont need to :
And I hope that I will
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey! Sorry about the delay in this answer. Update: I got excited with this, and created a demo repo where I re-create a content structure mirroring what you've got in your links, to give you an idea of how everything works. The TL;DR of how you can pull schema-defined types in the frontend is here: https://github.com/simonswiss/keystatic-typesafety-demo/blob/main/src/app/(app)/page.tsx#L9-L15 I feel like Keystatic's Reader API does all you want, and means you don't need to define your schema/types in two different places. The schema you define in your config file will generate Types you can bring in your frontend templates. The Reader API gives you a mechanism to read data from your file system, and also import the Types generated from the schema definition. Check out this With it, you can get the type for a collection entry like so:
Hope this helps! |
Beta Was this translation helpful? Give feedback.
So i started picking apart the types behind the read api and it looks like we need this type exposed:
S…