import type { MarkdownHeading } from '@astrojs/markdown-remark'; import type * as rollup from 'rollup'; import type { DataEntry, RenderedContent } from '../../content/data-store.js'; import type { LiveCollectionError } from '../../content/loaders/errors.js'; import type { AstroComponentFactory } from '../../runtime/server/index.js'; import type { AstroConfig } from './config.js'; export interface AstroInstance { file: string; url: string | undefined; default: AstroComponentFactory; } export interface MarkdownInstance> { frontmatter: T; /** Absolute file path (e.g. `/home/user/projects/.../file.md`) */ file: string; /** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */ url: string | undefined; /** Component to render content in `.astro` files. Usage: `` */ Content: AstroComponentFactory; /** raw Markdown file content, excluding layout HTML and YAML frontmatter */ rawContent(): string; /** Markdown file compiled to HTML, excluding layout HTML */ compiledContent(): Promise; /** List of headings (h1 -> h6) with associated metadata */ getHeadings(): MarkdownHeading[]; default: AstroComponentFactory; } export interface MDXInstance> extends Omit, 'rawContent' | 'compiledContent'> { components: Record | undefined; } export interface MarkdownLayoutProps> { frontmatter: { file: MarkdownInstance['file']; url: MarkdownInstance['url']; } & T; file: MarkdownInstance['file']; url: MarkdownInstance['url']; headings: MarkdownHeading[]; rawContent: MarkdownInstance['rawContent']; compiledContent: MarkdownInstance['compiledContent']; } export interface MDXLayoutProps> extends Omit, 'rawContent' | 'compiledContent'> { components: MDXInstance['components']; } export type ContentEntryModule = { id: string; collection: string; slug: string; body: string; data: Record; _internal: { rawData: string; filePath: string; }; }; export type DataEntryModule = { id: string; collection: string; data: Record; _internal: { rawData: string; filePath: string; }; }; export type ContentEntryRenderFunction = (entry: DataEntry) => Promise; export interface ContentEntryType { extensions: string[]; getEntryInfo(params: { fileUrl: URL; contents: string; }): GetContentEntryInfoReturnType | Promise; getRenderModule?(this: rollup.PluginContext, params: { contents: string; fileUrl: URL; viteId: string; }): rollup.LoadResult | Promise; contentModuleTypes?: string; getRenderFunction?(config: AstroConfig): Promise; /** * Handle asset propagation for rendered content to avoid bleed. * Ex. MDX content can import styles and scripts, so `handlePropagation` should be true. * @default true */ handlePropagation?: boolean; } export interface RefreshContentOptions { loaders?: Array; context?: Record; } type GetContentEntryInfoReturnType = { data: Record; /** * Used for error hints to point to correct line and location * Should be the untouched data as read from the file, * including newlines */ rawData: string; body: string; slug: string; }; export interface DataEntryType { extensions: string[]; getEntryInfo(params: { fileUrl: URL; contents: string; }): GetDataEntryInfoReturnType | Promise; } export type GetDataEntryInfoReturnType = { data: Record; rawData?: string; }; export interface CacheHint { /** Cache tags */ tags?: Array; /** Maximum age of the response in seconds */ maxAge?: number; /** Last modified time of the content */ lastModified?: Date; } export interface LiveDataEntry = Record> { /** The ID of the entry. Unique per collection. */ id: string; /** The parsed entry data */ data: TData; /** A hint for how to cache this entry */ cacheHint?: CacheHint; } export interface LiveDataCollection = Record> { entries: Array>; /** A hint for how to cache this collection. Individual entries can also have cache hints */ cacheHint?: CacheHint; } export interface LiveDataCollectionResult = Record, TError extends Error = Error> { entries?: Array>; error?: TError | LiveCollectionError; cacheHint?: CacheHint; } export interface LiveDataEntryResult = Record, TError extends Error = Error> { entry?: LiveDataEntry; error?: TError | LiveCollectionError; cacheHint?: CacheHint; } export {};