/// /// import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark'; import type * as babel from '@babel/core'; import type { OutgoingHttpHeaders } from 'node:http'; import type { AddressInfo } from 'node:net'; import type * as rollup from 'rollup'; import type * as vite from 'vite'; import type { RemotePattern } from '../assets/utils/remotePattern.js'; import type { SerializedSSRManifest } from '../core/app/types.js'; import type { PageBuildData } from '../core/build/types.js'; import type { AstroConfigType } from '../core/config/index.js'; import type { AstroTimer } from '../core/config/timer.js'; import type { TSConfig } from '../core/config/tsconfig.js'; import type { AstroCookies } from '../core/cookies/index.js'; import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core.js'; import type { AstroPreferences } from '../preferences/index.js'; import type { AstroDevToolbar, DevToolbarCanvas } from '../runtime/client/dev-toolbar/toolbar.js'; import type { Icon } from '../runtime/client/dev-toolbar/ui-library/icons.js'; import type { DevToolbarBadge, DevToolbarButton, DevToolbarCard, DevToolbarHighlight, DevToolbarIcon, DevToolbarToggle, DevToolbarTooltip, DevToolbarWindow } from '../runtime/client/dev-toolbar/ui-library/index.js'; import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server/index.js'; import type { DeepPartial, OmitIndexSignature, Simplify } from '../type-utils.js'; import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js'; export { type AstroIntegrationLogger }; export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark'; export type { ExternalImageService, ImageService, LocalImageService, } from '../assets/services/service.js'; export type { GetImageResult, ImageInputFormat, ImageMetadata, ImageOutputFormat, ImageQuality, ImageQualityPreset, ImageTransform, UnresolvedImageTransform, } from '../assets/types.js'; export type { RemotePattern } from '../assets/utils/remotePattern.js'; export type { SSRManifest } from '../core/app/types.js'; export type { AstroCookieGetOptions, AstroCookieSetOptions, AstroCookies, } from '../core/cookies/index.js'; export interface AstroBuiltinProps { 'client:load'?: boolean; 'client:idle'?: boolean; 'client:media'?: string; 'client:visible'?: ClientVisibleOptions | boolean; 'client:only'?: boolean | string; } export type ClientVisibleOptions = Pick; export interface TransitionAnimation { name: string; delay?: number | string; duration?: number | string; easing?: string; fillMode?: string; direction?: string; } export interface TransitionAnimationPair { old: TransitionAnimation | TransitionAnimation[]; new: TransitionAnimation | TransitionAnimation[]; } export interface TransitionDirectionalAnimations { forwards: TransitionAnimationPair; backwards: TransitionAnimationPair; } export type TransitionAnimationValue = 'initial' | 'slide' | 'fade' | 'none' | TransitionDirectionalAnimations; export interface AstroClientDirectives { } export interface AstroBuiltinAttributes { 'class:list'?: Record | Record | Iterable | Iterable | string; 'set:html'?: any; 'set:text'?: any; 'is:raw'?: boolean; 'transition:animate'?: TransitionAnimationValue; 'transition:name'?: string; 'transition:persist'?: boolean | string; } export interface AstroDefineVarsAttribute { 'define:vars'?: any; } export interface AstroStyleAttributes { 'is:global'?: boolean; 'is:inline'?: boolean; } export interface AstroScriptAttributes { 'is:inline'?: boolean; } export interface AstroSlotAttributes { 'is:inline'?: boolean; } export interface AstroComponentMetadata { displayName: string; hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only'; hydrateArgs?: any; componentUrl?: string; componentExport?: { value: string; namespace?: boolean; }; astroStaticSlot: true; } /** The flags supported by the Astro CLI */ export interface CLIFlags { root?: string; site?: string; base?: string; host?: string | boolean; port?: number; config?: string; open?: string | boolean; } /** * Astro global available in all contexts in .astro files * * [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global) */ export interface AstroGlobal = Record, Self = AstroComponentFactory, Params extends Record = Record> extends AstroGlobalPartial, AstroSharedContext { /** * A full URL object of the request URL. * Equivalent to: `new URL(Astro.request.url)` * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#url) */ url: AstroSharedContext['url']; /** Parameters passed to a dynamic page generated using [getStaticPaths](https://docs.astro.build/en/reference/api-reference/#getstaticpaths) * * Example usage: * ```astro * --- * export async function getStaticPaths() { * return [ * { params: { id: '1' } }, * ]; * } * * const { id } = Astro.params; * --- *

{id}

* ``` * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroparams) */ params: AstroSharedContext['params']; /** List of props passed to this component * * A common way to get specific props is through [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment), ex: * ```typescript * const { name } = Astro.props * ``` * * [Astro reference](https://docs.astro.build/en/basics/astro-components/#component-props) */ props: AstroSharedContext['props']; /** Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object * * For example, to get a URL object of the current URL, you can use: * ```typescript * const url = new URL(Astro.request.url); * ``` * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrorequest) */ request: Request; /** Information about the outgoing response. This is a standard [ResponseInit](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#init) object * * For example, to change the status code you can set a different status on this object: * ```typescript * Astro.response.status = 404; * ``` * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroresponse) */ response: ResponseInit & { readonly headers: Headers; }; /** Redirect to another page (**SSR Only**) * * Example usage: * ```typescript * if(!isLoggedIn) { * return Astro.redirect('/login'); * } * ``` * * [Astro reference](https://docs.astro.build/en/guides/server-side-rendering/) */ redirect: AstroSharedContext['redirect']; /** * The element allows a component to reference itself recursively. * * [Astro reference](https://docs.astro.build/en/guides/api-reference/#astroself) */ self: Self; /** Utility functions for modifying an Astro component’s slotted children * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots) */ slots: Record & { /** * Check whether content for this slot name exists * * Example usage: * ```typescript * if (Astro.slots.has('default')) { * // Do something... * } * ``` * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots) */ has(slotName: string): boolean; /** * Asynchronously renders this slot and returns a string * * Example usage: * ```astro * --- * let html: string = ''; * if (Astro.slots.has('default')) { * html = await Astro.slots.render('default') * } * --- * * ``` * * A second parameters can be used to pass arguments to a slotted callback * * Example usage: * ```astro * --- * html = await Astro.slots.render('default', ["Hello", "World"]) * --- * ``` * Each item in the array will be passed as an argument that you can use like so: * ```astro * * {(hello, world) =>
{hello}, {world}!
} *
* ``` * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots) */ render(slotName: string, args?: any[]): Promise; }; } /** Union type of supported markdown file extensions */ type MarkdowFileExtension = (typeof SUPPORTED_MARKDOWN_FILE_EXTENSIONS)[number]; export interface AstroGlobalPartial { /** * Fetch local files into your static site setup * * Example usage: * ```typescript * const posts = await Astro.glob('../pages/post/*.md'); * ``` * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroglob) */ glob(globStr: `${any}.astro`): Promise; glob>(globStr: `${any}${MarkdowFileExtension}`): Promise[]>; glob>(globStr: `${any}.mdx`): Promise[]>; glob>(globStr: string): Promise; /** * Returns a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object built from the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrosite) */ site: URL | undefined; /** * Returns a string with the current version of Astro. * * Useful for using `` or crediting Astro in a site footer. * * [HTML Specification for `generator`](https://html.spec.whatwg.org/multipage/semantics.html#meta-generator) * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrogenerator) */ generator: string; } type ServerConfig = { /** * @name server.host * @type {string | boolean} * @default `false` * @version 0.24.0 * @description * Set which network IP addresses the dev server should listen on (i.e. non-localhost IPs). * - `false` - do not expose on a network IP address * - `true` - listen on all addresses, including LAN and public addresses * - `[custom-address]` - expose on a network IP address at `[custom-address]` */ host?: string | boolean; /** * @name server.port * @type {number} * @default `4321` * @description * Set which port the dev server should listen on. * * If the given port is already in use, Astro will automatically try the next available port. */ port?: number; /** * @name server.headers * @typeraw {OutgoingHttpHeaders} * @default `{}` * @version 1.7.0 * @description * Set custom HTTP response headers to be sent in `astro dev` and `astro preview`. */ headers?: OutgoingHttpHeaders; /** * @name server.open * @type {string | boolean} * @default `false` * @version 4.1.0 * @description * Controls whether the dev server should open in your browser window on startup. * * Pass a full URL string (e.g. "http://example.com") or a pathname (e.g. "/about") to specify the URL to open. * * ```js * { * server: { open: "/about" } * } * ``` */ open?: string | boolean; }; export interface ViteUserConfig extends vite.UserConfig { ssr?: vite.SSROptions; } export interface ImageServiceConfig = Record> { entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | (string & {}); config?: T; } /** * Astro User Config * Docs: https://docs.astro.build/reference/configuration-reference/ */ export interface AstroUserConfig { /** * @docs * @kind heading * @name Top-Level Options */ /** * @docs * @name site * @type {string} * @description * Your final, deployed URL. Astro uses this full URL to generate your sitemap and canonical URLs in your final build. It is strongly recommended that you set this configuration to get the most out of Astro. * * ```js * { * site: 'https://www.my-site.dev' * } * ``` */ site?: string; /** * @docs * @name base * @type {string} * @description * The base path to deploy to. Astro will use this path as the root for your pages and assets both in development and in production build. * * In the example below, `astro dev` will start your server at `/docs`. * * ```js * { * base: '/docs' * } * ``` * * When using this option, all of your static asset imports and URLs should add the base as a prefix. You can access this value via `import.meta.env.BASE_URL`. * * The value of `import.meta.env.BASE_URL` will be determined by your `trailingSlash` config, no matter what value you have set for `base`. * * A trailing slash is always included if `trailingSlash: "always"` is set. If `trailingSlash: "never"` is set, `BASE_URL` will not include a trailing slash, even if `base` includes one. * * Additionally, Astro will internally manipulate the configured value of `config.base` before making it available to integrations. The value of `config.base` as read by integrations will also be determined by your `trailingSlash` configuration in the same way. * * In the example below, the values of `import.meta.env.BASE_URL` and `config.base` when processed will both be `/docs`: * ```js * { * base: '/docs/', * trailingSlash: "never" * } * ``` * * In the example below, the values of `import.meta.env.BASE_URL` and `config.base` when processed will both be `/docs/`: * * ```js * { * base: '/docs', * trailingSlash: "always" * } * ``` */ base?: string; /** * @docs * @name trailingSlash * @type {('always' | 'never' | 'ignore')} * @default `'ignore'` * @see build.format * @description * * Set the route matching behavior of the dev server. Choose from the following options: * - `'always'` - Only match URLs that include a trailing slash (ex: "/foo/") * - `'never'` - Never match URLs that include a trailing slash (ex: "/foo") * - `'ignore'` - Match URLs regardless of whether a trailing "/" exists * * Use this configuration option if your production host has strict handling of how trailing slashes work or do not work. * * You can also set this if you prefer to be more strict yourself, so that URLs with or without trailing slashes won't work during development. * * ```js * { * // Example: Require a trailing slash during development * trailingSlash: 'always' * } * ``` */ trailingSlash?: 'always' | 'never' | 'ignore'; /** * @docs * @name redirects * @type {Record} * @default `{}` * @version 2.9.0 * @description Specify a mapping of redirects where the key is the route to match * and the value is the path to redirect to. * * You can redirect both static and dynamic routes, but only to the same kind of route. * For example you cannot have a `'/article': '/blog/[...slug]'` redirect. * * * ```js * { * redirects: { * '/old': '/new', * '/blog/[...slug]': '/articles/[...slug]', * } * } * ``` * * * For statically-generated sites with no adapter installed, this will produce a client redirect using a [`` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#http-equiv) and does not support status codes. * * When using SSR or with a static adapter in `output: static` * mode, status codes are supported. * Astro will serve redirected GET requests with a status of `301` * and use a status of `308` for any other request method. * * You can customize the [redirection status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages) using an object in the redirect config: * * ```js * { * redirects: { * '/other': { * status: 302, * destination: '/place', * }, * } * } * ``` */ redirects?: Record; /** * @docs * @name output * @type {('static' | 'server' | 'hybrid')} * @default `'static'` * @see adapter * @description * * Specifies the output target for builds. * * - `'static'` - Building a static site to be deployed to any static host. * - `'server'` - Building an app to be deployed to a host supporting SSR (server-side rendering). * - `'hybrid'` - Building a static site with a few server-side rendered pages. * * ```js * import { defineConfig } from 'astro/config'; * * export default defineConfig({ * output: 'static' * }) * ``` */ output?: 'static' | 'server' | 'hybrid'; /** * @docs * @name adapter * @typeraw {AstroIntegration} * @see output * @description * * Deploy to your favorite server, serverless, or edge host with build adapters. Import one of our first-party adapters for [Netlify](https://docs.astro.build/en/guides/deploy/netlify/#adapter-for-ssr), [Vercel](https://docs.astro.build/en/guides/deploy/vercel/#adapter-for-ssr), and more to engage Astro SSR. * * [See our Server-side Rendering guide](https://docs.astro.build/en/guides/server-side-rendering/) for more on SSR, and [our deployment guides](https://docs.astro.build/en/guides/deploy/) for a complete list of hosts. * * ```js * import netlify from '@astrojs/netlify'; * { * // Example: Build for Netlify serverless deployment * adapter: netlify(), * } * ``` */ adapter?: AstroIntegration; /** * @docs * @name integrations * @typeraw {AstroIntegration[]} * @description * * Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown). * * Read our [Integrations Guide](https://docs.astro.build/en/guides/integrations-guide/) for help getting started with Astro Integrations. * * ```js * import react from '@astrojs/react'; * import tailwind from '@astrojs/tailwind'; * { * // Example: Add React + Tailwind support to Astro * integrations: [react(), tailwind()] * } * ``` */ integrations?: Array; /** * @docs * @name root * @cli --root * @type {string} * @default `"."` (current working directory) * @summary Set the project root. The project root is the directory where your Astro project (and all `src`, `public` and `package.json` files) live. * @description You should only provide this option if you run the `astro` CLI commands in a directory other than the project root directory. Usually, this option is provided via the CLI instead of the [Astro config file](https://docs.astro.build/en/guides/configuring-astro/#supported-config-file-types), since Astro needs to know your project root before it can locate your config file. * * If you provide a relative path (ex: `--root: './my-project'`) Astro will resolve it against your current working directory. * * #### Examples * * ```js * { * root: './my-project-directory' * } * ``` * ```bash * $ astro build --root ./my-project-directory * ``` */ root?: string; /** * @docs * @name srcDir * @type {string} * @default `"./src"` * @description Set the directory that Astro will read your site from. * * The value can be either an absolute file system path or a path relative to the project root. * * ```js * { * srcDir: './www' * } * ``` */ srcDir?: string; /** * @docs * @name publicDir * @type {string} * @default `"./public"` * @description * Set the directory for your static assets. Files in this directory are served at `/` during dev and copied to your build directory during build. These files are always served or copied as-is, without transform or bundling. * * The value can be either an absolute file system path or a path relative to the project root. * * ```js * { * publicDir: './my-custom-publicDir-directory' * } * ``` */ publicDir?: string; /** * @docs * @name outDir * @type {string} * @default `"./dist"` * @see build.server * @description Set the directory that `astro build` writes your final build to. * * The value can be either an absolute file system path or a path relative to the project root. * * ```js * { * outDir: './my-custom-build-directory' * } * ``` */ outDir?: string; /** * @docs * @name cacheDir * @type {string} * @default `"./node_modules/.astro"` * @description Set the directory for caching build artifacts. Files in this directory will be used in subsequent builds to speed up the build time. * * The value can be either an absolute file system path or a path relative to the project root. * * ```js * { * cacheDir: './my-custom-cache-directory' * } * ``` */ cacheDir?: string; /** * @docs * @name compressHTML * @type {boolean} * @default `true` * @description * This is an option to minify your HTML output and reduce the size of your HTML files. By default, Astro removes all whitespace from your HTML, including line breaks, from `.astro` components. This occurs both in development mode and in the final build. * To disable HTML compression, set the `compressHTML` flag to `false`. * * ```js * { * compressHTML: false * } * ``` */ compressHTML?: boolean; /** * @docs * @name scopedStyleStrategy * @type {('where' | 'class' | 'attribute')} * @default `'attribute'` * @version 2.4 * @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, causing no specificity increase. * - `'class'` - Use class-based selectors, causing a +1 specificity increase. * - `'attribute'` - Use `data-` attributes, causing a +1 specificity increase. * * Using `'class'` is helpful when you want to ensure that element selectors within an Astro component override global style defaults (e.g. from a global stylesheet). * Using `'where'` gives you more control over specificity, but requires that you use higher-specificity selectors, layers, and other tools to control which selectors are applied. * Using `'attribute'` is useful when you are manipulating the `class` attribute of elements and need to avoid conflicts between your own styling logic and Astro's application of styles. */ scopedStyleStrategy?: 'where' | 'class' | 'attribute'; /** * @docs * @name vite * @typeraw {ViteUserConfig} * @description * * Pass additional configuration options to Vite. Useful when Astro doesn't support some advanced configuration that you may need. * * View the full `vite` configuration object documentation on [vitejs.dev](https://vitejs.dev/config/). * * #### Examples * * ```js * { * vite: { * ssr: { * // Example: Force a broken package to skip SSR processing, if needed * external: ['broken-npm-package'], * } * } * } * ``` * * ```js * { * vite: { * // Example: Add custom vite plugins directly to your Astro project * plugins: [myPlugin()], * } * } * ``` */ vite?: ViteUserConfig; /** * @docs * @kind heading * @name Build Options */ build?: { /** * @docs * @name build.format * @typeraw {('file' | 'directory' | 'preserve')} * @default `'directory'` * @description * Control the output file format of each page. This value may be set by an adapter for you. * - `'file'`: Astro will generate an HTML file named for each page route. (e.g. `src/pages/about.astro` and `src/pages/about/index.astro` both build the file `/about.html`) * - `'directory'`: Astro will generate a directory with a nested `index.html` file for each page. (e.g. `src/pages/about.astro` and `src/pages/about/index.astro` both build the file `/about/index.html`) * - `'preserve'`: Astro will generate HTML files exactly as they appear in your source folder. (e.g. `src/pages/about.astro` builds `/about.html` and `src/pages/about/index.astro` builds the file `/about/index.html`) * * ```js * { * build: { * // Example: Generate `page.html` instead of `page/index.html` during build. * format: 'file' * } * } * ``` * * * * #### Effect on Astro.url * Setting `build.format` controls what `Astro.url` is set to during the build. When it is: * - `directory` - The `Astro.url.pathname` will include a trailing slash to mimic folder behavior; ie `/foo/`. * - `file` - The `Astro.url.pathname` will include `.html`; ie `/foo.html`. * * This means that when you create relative URLs using `new URL('./relative', Astro.url)`, you will get consistent behavior between dev and build. * * To prevent inconsistencies with trailing slash behaviour in dev, you can restrict the [`trailingSlash` option](#trailingslash) to `'always'` or `'never'` depending on your build format: * - `directory` - Set `trailingSlash: 'always'` * - `file` - Set `trailingSlash: 'never'` */ format?: 'file' | 'directory' | 'preserve'; /** * @docs * @name build.client * @type {string} * @default `'./dist/client'` * @description * Controls the output directory of your client-side CSS and JavaScript when `output: 'server'` or `output: 'hybrid'` only. * `outDir` controls where the code is built to. * * This value is relative to the `outDir`. * * ```js * { * output: 'server', // or 'hybrid' * build: { * client: './client' * } * } * ``` */ client?: string; /** * @docs * @name build.server * @type {string} * @default `'./dist/server'` * @description * Controls the output directory of server JavaScript when building to SSR. * * This value is relative to the `outDir`. * * ```js * { * build: { * server: './server' * } * } * ``` */ server?: string; /** * @docs * @name build.assets * @type {string} * @default `'_astro'` * @see outDir * @version 2.0.0 * @description * Specifies the directory in the build output where Astro-generated assets (bundled JS and CSS for example) should live. * * ```js * { * build: { * assets: '_custom' * } * } * ``` */ assets?: string; /** * @docs * @name build.assetsPrefix * @type {string} * @default `undefined` * @version 2.2.0 * @description * Specifies the prefix for Astro-generated asset links. This can be used if assets are served from a different domain than the current site. * * For example, if this is set to `https://cdn.example.com`, assets will be fetched from `https://cdn.example.com/_astro/...` (regardless of the `base` option). * You would need to upload the files in `./dist/_astro/` to `https://cdn.example.com/_astro/` to serve the assets. * The process varies depending on how the third-party domain is hosted. * To rename the `_astro` path, specify a new directory in `build.assets`. * * ```js * { * build: { * assetsPrefix: 'https://cdn.example.com' * } * } * ``` */ assetsPrefix?: string; /** * @docs * @name build.serverEntry * @type {string} * @default `'entry.mjs'` * @description * Specifies the file name of the server entrypoint when building to SSR. * This entrypoint is usually dependent on which host you are deploying to and * will be set by your adapter for you. * * Note that it is recommended that this file ends with `.mjs` so that the runtime * detects that the file is a JavaScript module. * * ```js * { * build: { * serverEntry: 'main.mjs' * } * } * ``` */ serverEntry?: string; /** * @docs * @name build.redirects * @type {boolean} * @default `true` * @version 2.6.0 * @description * Specifies whether redirects will be output to HTML during the build. * This option only applies to `output: 'static'` mode; in SSR redirects * are treated the same as all responses. * * This option is mostly meant to be used by adapters that have special * configuration files for redirects and do not need/want HTML based redirects. * * ```js * { * build: { * redirects: false * } * } * ``` */ redirects?: boolean; /** * @docs * @name build.inlineStylesheets * @type {('always' | 'auto' | 'never')} * @default `auto` * @version 2.6.0 * @description * Control whether project styles are sent to the browser in a separate css file or inlined into `