summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Andrew Moore <andrewm.finewolf@gmail.com> 2023-09-13 15:16:00 -0400
committerGravatar GitHub <noreply@github.com> 2023-09-13 21:16:00 +0200
commit45364c345267429e400baecd1fbc290503f8b13a (patch)
tree93de9fcdc9e3c2a67dd2e3a7319aed020a441887
parent91380378cef545656d2c085117fc5f38c9ce4589 (diff)
downloadastro-45364c345267429e400baecd1fbc290503f8b13a.tar.gz
astro-45364c345267429e400baecd1fbc290503f8b13a.tar.zst
astro-45364c345267429e400baecd1fbc290503f8b13a.zip
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 <natemoo-re@users.noreply.github.com> Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
-rw-r--r--.changeset/small-apes-clap.md5
-rw-r--r--packages/astro/content-types.template.d.ts11
2 files changed, 13 insertions, 3 deletions
diff --git a/.changeset/small-apes-clap.md b/.changeset/small-apes-clap.md
new file mode 100644
index 000000000..1a682604a
--- /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 596764fe6..8e5b59c39 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> = T extends { [K: string]: infer U } ? U : never;
- export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
+
+ type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
+
+ export type CollectionKey = keyof AnyEntryMap;
+ export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
+
+ 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<{