website-astro/.astro/types.d.ts

274 lines
6.8 KiB
TypeScript
Raw Normal View History

2022-12-22 11:18:44 +01:00
declare module 'astro:content' {
export { z } from 'astro/zod';
export type CollectionEntry<C extends keyof typeof entryMap> =
2023-02-03 11:21:01 +01:00
(typeof entryMap)[C][keyof (typeof entryMap)[C]] & Render;
2022-12-22 11:18:44 +01:00
2023-02-03 11:21:01 +01:00
type BaseSchemaWithoutEffects =
| import('astro/zod').AnyZodObject
| import('astro/zod').ZodUnion<import('astro/zod').AnyZodObject[]>
| import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
| import('astro/zod').ZodIntersection<
import('astro/zod').AnyZodObject,
import('astro/zod').AnyZodObject
>;
type BaseSchema =
| BaseSchemaWithoutEffects
| import('astro/zod').ZodEffects<BaseSchemaWithoutEffects>;
type BaseCollectionConfig<S extends BaseSchema> = {
2022-12-22 11:18:44 +01:00
schema?: S;
slug?: (entry: {
id: CollectionEntry<keyof typeof entryMap>['id'];
defaultSlug: string;
collection: string;
body: string;
2023-02-03 11:21:01 +01:00
data: import('astro/zod').infer<S>;
2022-12-22 11:18:44 +01:00
}) => string | Promise<string>;
};
2023-02-03 11:21:01 +01:00
export function defineCollection<S extends BaseSchema>(
2022-12-22 11:18:44 +01:00
input: BaseCollectionConfig<S>
): BaseCollectionConfig<S>;
2023-02-03 11:21:01 +01:00
type EntryMapKeys = keyof typeof entryMap;
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
type ValidEntrySlug<C extends EntryMapKeys> = AllValuesOf<(typeof entryMap)[C]>['slug'];
export function getEntryBySlug<
2022-12-22 11:18:44 +01:00
C extends keyof typeof entryMap,
2023-02-03 11:21:01 +01:00
E extends ValidEntrySlug<C> | (string & {})
2022-12-22 11:18:44 +01:00
>(
collection: C,
2023-02-03 11:21:01 +01:00
// Note that this has to accept a regular string too, for SSR
entrySlug: E
): E extends ValidEntrySlug<C>
? Promise<CollectionEntry<C>>
: Promise<CollectionEntry<C> | undefined>;
export function getCollection<C extends keyof typeof entryMap, E extends CollectionEntry<C>>(
collection: C,
filter?: (entry: CollectionEntry<C>) => entry is E
): Promise<E[]>;
export function getCollection<C extends keyof typeof entryMap>(
collection: C,
filter?: (entry: CollectionEntry<C>) => unknown
): Promise<CollectionEntry<C>[]>;
2022-12-22 11:18:44 +01:00
type InferEntrySchema<C extends keyof typeof entryMap> = import('astro/zod').infer<
2023-02-03 11:21:01 +01:00
Required<ContentConfig['collections'][C]>['schema']
2022-12-22 11:18:44 +01:00
>;
type Render = {
render(): Promise<{
Content: import('astro').MarkdownInstance<{}>['Content'];
headings: import('astro').MarkdownHeading[];
2023-02-03 11:21:01 +01:00
remarkPluginFrontmatter: Record<string, any>;
2022-12-22 11:18:44 +01:00
}>;
};
const entryMap: {
"articles": {
2022-12-28 10:36:15 +01:00
"en/2022.md": {
id: "en/2022.md",
2023-02-03 11:21:01 +01:00
slug: "2022",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"en/after-effects-expressions.mdx": {
id: "en/after-effects-expressions.mdx",
2023-02-03 11:21:01 +01:00
slug: "after-effects-expressions",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"en/faq.md": {
id: "en/faq.md",
2023-02-03 11:21:01 +01:00
slug: "faq",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"en/gratuiste.md": {
id: "en/gratuiste.md",
2023-02-03 11:21:01 +01:00
slug: "gratuiste",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"en/sci-hub-blocage.mdx": {
id: "en/sci-hub-blocage.mdx",
2023-02-03 11:21:01 +01:00
slug: "sci-hub-unblock",
2022-12-22 11:18:44 +01:00
body: string,
collection: "articles",
2022-12-26 23:15:27 +01:00
data: InferEntrySchema<"articles">
2022-12-22 11:18:44 +01:00
},
2022-12-28 10:36:15 +01:00
"en/the-day-I-jamd.mdx": {
id: "en/the-day-I-jamd.mdx",
2023-02-03 11:21:01 +01:00
slug: "the-day-I-jamd",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
2023-02-03 10:37:28 +01:00
"en/video-compression.mdx": {
id: "en/video-compression.mdx",
2023-02-03 11:21:01 +01:00
slug: "video-compression",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"fr/2022.md": {
id: "fr/2022.md",
2023-02-03 11:21:01 +01:00
slug: "2022",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"fr/after-effects-expressions.md": {
id: "fr/after-effects-expressions.md",
2023-02-03 11:21:01 +01:00
slug: "after-effects-expressions",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"fr/faq.md": {
id: "fr/faq.md",
2023-02-03 11:21:01 +01:00
slug: "faq",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"fr/gratuiste.md": {
id: "fr/gratuiste.md",
2023-02-03 11:21:01 +01:00
slug: "gratuiste",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"fr/sci-hub-blocage.mdx": {
id: "fr/sci-hub-blocage.mdx",
2023-02-03 11:21:01 +01:00
slug: "sci-hub-blocage",
2022-12-22 11:18:44 +01:00
body: string,
collection: "articles",
2022-12-26 23:15:27 +01:00
data: InferEntrySchema<"articles">
2022-12-22 11:18:44 +01:00
},
2022-12-28 10:36:15 +01:00
"fr/the-day-I-jamd.mdx": {
id: "fr/the-day-I-jamd.mdx",
2023-02-03 11:21:01 +01:00
slug: "the-day-I-jamd",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
"fr/video-compression.md": {
id: "fr/video-compression.md",
2023-02-03 11:21:01 +01:00
slug: "video-compression",
2022-12-28 10:36:15 +01:00
body: string,
collection: "articles",
data: InferEntrySchema<"articles">
},
},
"fragments": {
"en/acme-sh-tls-cert.md": {
id: "en/acme-sh-tls-cert.md",
2023-02-03 11:21:01 +01:00
slug: "acme-sh-tls-cert",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"en/array-vs-array.md": {
id: "en/array-vs-array.md",
2023-02-03 11:21:01 +01:00
slug: "array-vs-array",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"en/buttons.md": {
id: "en/buttons.md",
2023-02-03 11:21:01 +01:00
slug: "buttons",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
2023-02-03 10:37:28 +01:00
"en/image-full.mdx": {
id: "en/image-full.mdx",
2023-02-03 11:21:01 +01:00
slug: "image-full",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"en/nuxt-graphql-static.md": {
id: "en/nuxt-graphql-static.md",
2023-02-03 11:21:01 +01:00
slug: "nuxt-graphql-static",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"en/super-cookies.md": {
id: "en/super-cookies.md",
2023-02-03 11:21:01 +01:00
slug: "super-cookies",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"en/toulouse-fun.md": {
id: "en/toulouse-fun.md",
2023-02-03 11:21:01 +01:00
slug: "toulouse-fun",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"fr/acme-sh-tls-cert.md": {
id: "fr/acme-sh-tls-cert.md",
2023-02-03 11:21:01 +01:00
slug: "acme-sh-tls-cert",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"fr/array-vs-array.md": {
id: "fr/array-vs-array.md",
2023-02-03 11:21:01 +01:00
slug: "array-vs-array",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
2023-02-03 10:37:28 +01:00
"fr/buttons.mdx": {
id: "fr/buttons.mdx",
2023-02-03 11:21:01 +01:00
slug: "buttons",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
2023-02-03 10:37:28 +01:00
"fr/image-full.mdx": {
id: "fr/image-full.mdx",
2023-02-03 11:21:01 +01:00
slug: "image-full",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"fr/nuxt-graphql-static.md": {
id: "fr/nuxt-graphql-static.md",
2023-02-03 11:21:01 +01:00
slug: "nuxt-graphql-static",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"fr/super-cookies.md": {
id: "fr/super-cookies.md",
2023-02-03 11:21:01 +01:00
slug: "super-cookies",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
"fr/toulouse-fun.md": {
id: "fr/toulouse-fun.md",
2023-02-03 11:21:01 +01:00
slug: "toulouse-fun",
2022-12-28 10:36:15 +01:00
body: string,
collection: "fragments",
data: InferEntrySchema<"fragments">
},
2022-12-22 11:18:44 +01:00
},
};
2023-02-03 11:21:01 +01:00
type ContentConfig = typeof import("../src/content/config");
2022-12-22 11:18:44 +01:00
}