Ingo Steinke is a Berlin-based senior web developer focusing on front-end web development to create and improve websites and make the web more accessible, sustainable, and user-friendly.
I discovered Zod as Astro recommends or expects it when using MDX front matter content collections with TypeScript, and I found it very useful. Despite the "single source of truth", I still have more than a single place to edit my type definitions, e.g.
I discovered Zod as Astro recommends or expects it when using MDX front matter content collections with TypeScript, and I found it very useful. Despite the "single source of truth", I still have more than a single place to edit my type definitions, e.g.
and
I wondered if there is an elegant way to avoid this data duplication. Update: I eventually found out about type inference like this ...
... but still struggled to make it work.
Infer Astro Zod Content Schema in TSX React Components avoiding Code Duplication
Ingo Steinke, web developer ・ Aug 28