From 45364c345267429e400baecd1fbc290503f8b13a Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Wed, 13 Sep 2023 15:16:00 -0400 Subject: [PATCH] feat: added types to allow the creation of user space content services (#7607) * feat: added types to astro:content to allow user space content services * Create small-apes-clap.md --------- Co-authored-by: Nate Moore Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> --- .changeset/small-apes-clap.md | 5 +++++ packages/astro/content-types.template.d.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/small-apes-clap.md diff --git a/.changeset/small-apes-clap.md b/.changeset/small-apes-clap.md new file mode 100644 index 0000000000..1a682604af --- /dev/null +++ b/.changeset/small-apes-clap.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Add `CollectionKey`, `ContentCollectionKey`, and `DataCollectionKey` exports to `astro:content` diff --git a/packages/astro/content-types.template.d.ts b/packages/astro/content-types.template.d.ts index 596764fe65..8e5b59c39a 100644 --- a/packages/astro/content-types.template.d.ts +++ b/packages/astro/content-types.template.d.ts @@ -10,9 +10,14 @@ declare module 'astro:content' { declare module 'astro:content' { export { z } from 'astro/zod'; + + type Flatten = T extends { [K: string]: infer U } ? U : never; + + export type CollectionKey = keyof AnyEntryMap; + export type CollectionEntry = Flatten; - type Flatten = T extends { [K: string]: infer U } ? U : never; - export type CollectionEntry = Flatten; + export type ContentCollectionKey = keyof ContentEntryMap; + export type DataCollectionKey = keyof DataEntryMap; // This needs to be in sync with ImageMetadata export type ImageFunction = () => import('astro/zod').ZodObject<{