#Use `CollectionKey` in integration

2 messages · Page 1 of 1 (latest)

silk quest
#

Hey folks, I'm currently creating an Astro integration for Polar (https://polar.sh), and I'd like to be able to use the ContentCollectionKey and CollectionEntry types from astro:content, but they're not available (unless I've set something up incorrectly).

Is there a good way to achieve this?

timid mesa
#

Hi there, yeah this is a problem when making integrations! Unless your project has the generated types then using those functions you'll lose typings! And I'm guessing this integration can be installed on any project so won't have the typings itself.

The best thing to do is just to cast your data as types yourself. You can get the types from your zod schemas with z.infer<typeof MySchema>.

Although this is how I achieved it with astro-blog. Also when it comes to integration, the #integrations channel is amazing and you may find slightly more integration focussed help there for more advanced use cases!