Skip to content

Commit eb35d45

Browse files
committed
Upgrade to astro2
1 parent 5338997 commit eb35d45

File tree

4 files changed

+17882
-18361
lines changed

4 files changed

+17882
-18361
lines changed

.astro/types.d.ts

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
declare module 'astro:content' {
2+
export { z } from 'astro/zod';
3+
export type CollectionEntry<C extends keyof typeof entryMap> =
4+
(typeof entryMap)[C][keyof (typeof entryMap)[C]] & Render;
5+
6+
type BaseSchemaWithoutEffects =
7+
| import('astro/zod').AnyZodObject
8+
| import('astro/zod').ZodUnion<import('astro/zod').AnyZodObject[]>
9+
| import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
10+
| import('astro/zod').ZodIntersection<
11+
import('astro/zod').AnyZodObject,
12+
import('astro/zod').AnyZodObject
13+
>;
14+
15+
type BaseSchema =
16+
| BaseSchemaWithoutEffects
17+
| import('astro/zod').ZodEffects<BaseSchemaWithoutEffects>;
18+
19+
type BaseCollectionConfig<S extends BaseSchema> = {
20+
schema?: S;
21+
slug?: (entry: {
22+
id: CollectionEntry<keyof typeof entryMap>['id'];
23+
defaultSlug: string;
24+
collection: string;
25+
body: string;
26+
data: import('astro/zod').infer<S>;
27+
}) => string | Promise<string>;
28+
};
29+
export function defineCollection<S extends BaseSchema>(
30+
input: BaseCollectionConfig<S>
31+
): BaseCollectionConfig<S>;
32+
33+
type EntryMapKeys = keyof typeof entryMap;
34+
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
35+
type ValidEntrySlug<C extends EntryMapKeys> = AllValuesOf<(typeof entryMap)[C]>['slug'];
36+
37+
export function getEntryBySlug<
38+
C extends keyof typeof entryMap,
39+
E extends ValidEntrySlug<C> | (string & {})
40+
>(
41+
collection: C,
42+
// Note that this has to accept a regular string too, for SSR
43+
entrySlug: E
44+
): E extends ValidEntrySlug<C>
45+
? Promise<CollectionEntry<C>>
46+
: Promise<CollectionEntry<C> | undefined>;
47+
export function getCollection<C extends keyof typeof entryMap>(
48+
collection: C,
49+
filter?: (data: CollectionEntry<C>) => boolean
50+
): Promise<CollectionEntry<C>[]>;
51+
52+
type InferEntrySchema<C extends keyof typeof entryMap> = import('astro/zod').infer<
53+
Required<ContentConfig['collections'][C]>['schema']
54+
>;
55+
56+
type Render = {
57+
render(): Promise<{
58+
Content: import('astro').MarkdownInstance<{}>['Content'];
59+
headings: import('astro').MarkdownHeading[];
60+
remarkPluginFrontmatter: Record<string, any>;
61+
}>;
62+
};
63+
64+
const entryMap: {
65+
66+
};
67+
68+
type ContentConfig = typeof import("../src/content/config");
69+
}

0 commit comments

Comments
 (0)