/// import matter from 'gray-matter'; import fsMod from 'node:fs'; import type { PluginContext } from 'rollup'; import { type ViteDevServer } from 'vite'; import { z } from 'zod'; import type { AstroConfig, AstroSettings, ContentEntryType, DataEntryType } from '../@types/astro.js'; import { CONTENT_FLAGS } from './consts.js'; /** * Amap from a collection + slug to the local file path. * This is used internally to resolve entry imports when using `getEntry()`. * @see `content-module.template.mjs` */ export type ContentLookupMap = { [collectionName: string]: { type: 'content' | 'data'; entries: { [lookupId: string]: string; }; }; }; export declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{ type: z.ZodDefault>>; schema: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "content"; schema?: any; }, { type?: "content" | undefined; schema?: any; }>, z.ZodObject<{ type: z.ZodLiteral<"data">; schema: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "data"; schema?: any; }, { type: "data"; schema?: any; }>]>; export declare function getDotAstroTypeReference({ root, srcDir }: { root: URL; srcDir: URL; }): string; export declare const contentConfigParser: z.ZodObject<{ collections: z.ZodRecord>>; schema: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "content"; schema?: any; }, { type?: "content" | undefined; schema?: any; }>, z.ZodObject<{ type: z.ZodLiteral<"data">; schema: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "data"; schema?: any; }, { type: "data"; schema?: any; }>]>>; }, "strip", z.ZodTypeAny, { collections: Record; }, { collections: Record; }>; export type CollectionConfig = z.infer; export type ContentConfig = z.infer; type EntryInternal = { rawData: string | undefined; filePath: string; }; export declare const msg: { collectionConfigMissing: (collection: string) => string; }; export declare function parseEntrySlug({ id, collection, generatedSlug, frontmatterSlug, }: { id: string; collection: string; generatedSlug: string; frontmatterSlug?: unknown; }): string; export declare function getEntryData(entry: { id: string; collection: string; unvalidatedData: Record; _internal: EntryInternal; }, collectionConfig: CollectionConfig, pluginContext: PluginContext): Promise; export declare function getContentEntryExts(settings: Pick): string[]; export declare function getDataEntryExts(settings: Pick): string[]; export declare function getEntryConfigByExtMap(entryTypes: TEntryType[]): Map; export declare function getEntryCollectionName({ contentDir, entry, }: Pick & { entry: string | URL; }): string | undefined; export declare function getDataEntryId({ entry, contentDir, collection, }: Pick & { entry: URL; collection: string; }): string; export declare function getContentEntryIdAndSlug({ entry, contentDir, collection, }: Pick & { entry: URL; collection: string; }): { id: string; slug: string; }; export declare function getEntryType(entryPath: string, paths: Pick, contentFileExts: string[], dataFileExts: string[]): 'content' | 'data' | 'config' | 'ignored'; export declare function hasUnderscoreBelowContentDirectoryPath(fileUrl: URL, contentDir: ContentPaths['contentDir']): boolean; export declare function parseFrontmatter(fileContents: string): matter.GrayMatterFile; /** * The content config is loaded separately from other `src/` files. * This global observable lets dependent plugins (like the content flag plugin) * subscribe to changes during dev server updates. */ export declare const globalContentConfigObserver: ContentObservable; export declare function hasAnyContentFlag(viteId: string): boolean; export declare function hasContentFlag(viteId: string, flag: (typeof CONTENT_FLAGS)[number]): boolean; export declare function loadContentConfig({ fs, settings, viteServer, }: { fs: typeof fsMod; settings: AstroSettings; viteServer: ViteDevServer; }): Promise; export declare function reloadContentConfigObserver({ observer, ...loadContentConfigOpts }: { fs: typeof fsMod; settings: AstroSettings; viteServer: ViteDevServer; observer?: ContentObservable; }): Promise; type ContentCtx = { status: 'init'; } | { status: 'loading'; } | { status: 'does-not-exist'; } | { status: 'loaded'; config: ContentConfig; } | { status: 'error'; error: Error; }; type Observable = { get: () => C; set: (ctx: C) => void; subscribe: (fn: (ctx: C) => void) => () => void; }; export type ContentObservable = Observable; export declare function contentObservable(initialCtx: ContentCtx): ContentObservable; export type ContentPaths = { contentDir: URL; assetsDir: URL; cacheDir: URL; typesTemplate: URL; virtualModTemplate: URL; config: { exists: boolean; url: URL; }; }; export declare function getContentPaths({ srcDir, root }: Pick, fs?: typeof fsMod): ContentPaths; /** * Check for slug in content entry frontmatter and validate the type, * falling back to the `generatedSlug` if none is found. */ export declare function getEntrySlug({ id, collection, generatedSlug, contentEntryType, fileUrl, fs, }: { fs: typeof fsMod; id: string; collection: string; generatedSlug: string; fileUrl: URL; contentEntryType: Pick; }): Promise; export declare function getExtGlob(exts: string[]): string; export {};