Skip to content

Commit

Permalink
feat: added types to allow the creation of user space content services (
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
3 people authored Sep 13, 2023
1 parent 9138037 commit 45364c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-apes-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Add `CollectionKey`, `ContentCollectionKey`, and `DataCollectionKey` exports to `astro:content`
11 changes: 8 additions & 3 deletions packages/astro/content-types.template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand Down

0 comments on commit 45364c3

Please sign in to comment.