astro 0.25.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/astro.js +0 -0
- package/dist/@types/serialize-javascript.d.js +0 -0
- package/dist/@types/shorthash.d.js +0 -0
- package/dist/adapter-ssg/index.js +0 -0
- package/dist/cli/check.js +4 -4
- package/dist/cli/index.js +21 -32
- package/dist/core/add/babel.js +0 -0
- package/dist/core/add/consts.js +0 -0
- package/dist/core/add/imports.js +0 -0
- package/dist/core/add/index.js +7 -14
- package/dist/core/add/wrapper.js +0 -0
- package/dist/core/app/common.js +0 -0
- package/dist/core/app/index.js +13 -10
- package/dist/core/app/node.js +0 -0
- package/dist/core/app/types.js +0 -0
- package/dist/core/build/add-rollup-input.js +0 -0
- package/dist/core/build/common.js +4 -5
- package/dist/core/build/generate.js +65 -72
- package/dist/core/build/index.js +59 -74
- package/dist/core/build/internal.js +4 -0
- package/dist/core/build/page-data.js +10 -9
- package/dist/core/build/static-build.js +46 -28
- package/dist/core/build/types.d.js +0 -0
- package/dist/core/build/util.js +0 -0
- package/dist/core/build/vite-plugin-hoisted-scripts.js +1 -1
- package/dist/core/build/vite-plugin-internals.js +0 -0
- package/dist/core/build/vite-plugin-pages.js +1 -0
- package/dist/core/build/vite-plugin-ssr.js +4 -2
- package/dist/core/config.js +87 -79
- package/dist/core/create-vite.js +12 -7
- package/dist/core/dev/index.js +8 -7
- package/dist/core/endpoint/dev/index.js +5 -10
- package/dist/core/endpoint/index.js +1 -3
- package/dist/core/errors.js +45 -0
- package/dist/core/logger/console.js +43 -0
- package/dist/core/logger/core.js +103 -0
- package/dist/core/logger/node.js +94 -0
- package/dist/core/messages.js +50 -24
- package/dist/core/path.js +0 -0
- package/dist/core/polyfill.js +0 -0
- package/dist/core/preview/index.js +8 -8
- package/dist/core/preview/util.js +3 -6
- package/dist/core/render/core.js +5 -6
- package/dist/core/render/dev/css.js +5 -6
- package/dist/core/render/dev/hmr.js +0 -0
- package/dist/core/render/dev/html.js +0 -0
- package/dist/core/render/dev/index.js +23 -36
- package/dist/core/render/paginate.js +0 -0
- package/dist/core/render/pretty-feed.js +103 -0
- package/dist/core/render/result.js +33 -15
- package/dist/core/render/route-cache.js +2 -2
- package/dist/core/render/rss.js +5 -4
- package/dist/core/render/script.js +0 -0
- package/dist/core/render/ssr-element.js +1 -1
- package/dist/core/render/util.js +26 -0
- package/dist/core/request.js +27 -0
- package/dist/core/routing/index.js +0 -0
- package/dist/core/routing/manifest/create.js +8 -6
- package/dist/core/routing/manifest/serialization.js +0 -0
- package/dist/core/routing/match.js +0 -0
- package/dist/core/routing/params.js +0 -0
- package/dist/core/routing/validation.js +1 -1
- package/dist/core/util.js +57 -125
- package/dist/integrations/index.js +9 -1
- package/dist/runtime/client/hmr.js +0 -0
- package/dist/runtime/client/idle.js +0 -0
- package/dist/runtime/client/load.js +0 -0
- package/dist/runtime/client/media.js +0 -0
- package/dist/runtime/client/only.js +0 -0
- package/dist/runtime/client/visible.js +0 -0
- package/dist/runtime/server/escape.js +0 -0
- package/dist/runtime/server/hydration.js +0 -0
- package/dist/runtime/server/index.js +42 -36
- package/dist/runtime/server/metadata.js +0 -0
- package/dist/runtime/server/util.js +0 -0
- package/dist/template/4xx.js +1 -1
- package/dist/template/5xx.js +0 -0
- package/dist/template/css.js +0 -0
- package/dist/types/@types/astro.d.ts +291 -233
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/core/add/index.d.ts +1 -1
- package/dist/types/core/build/common.d.ts +0 -1
- package/dist/types/core/build/generate.d.ts +1 -1
- package/dist/types/core/build/index.d.ts +1 -1
- package/dist/types/core/build/internal.d.ts +1 -0
- package/dist/types/core/build/page-data.d.ts +1 -1
- package/dist/types/core/build/vite-plugin-pages.d.ts +1 -0
- package/dist/types/core/config.d.ts +125 -116
- package/dist/types/core/create-vite.d.ts +1 -1
- package/dist/types/core/dev/index.d.ts +1 -1
- package/dist/types/core/endpoint/index.d.ts +1 -1
- package/dist/types/core/errors.d.ts +23 -0
- package/dist/types/core/logger/console.d.ts +4 -0
- package/dist/types/core/{logger.d.ts → logger/core.d.ts} +7 -22
- package/dist/types/core/logger/node.d.ts +34 -0
- package/dist/types/core/messages.d.ts +4 -2
- package/dist/types/core/preview/index.d.ts +1 -1
- package/dist/types/core/preview/util.d.ts +1 -2
- package/dist/types/core/render/core.d.ts +2 -3
- package/dist/types/core/render/dev/css.d.ts +0 -2
- package/dist/types/core/render/dev/index.d.ts +4 -6
- package/dist/types/core/render/pretty-feed.d.ts +2 -0
- package/dist/types/core/render/result.d.ts +2 -3
- package/dist/types/core/render/route-cache.d.ts +1 -1
- package/dist/types/core/render/util.d.ts +6 -0
- package/dist/types/core/request.d.ts +14 -0
- package/dist/types/core/routing/manifest/create.d.ts +1 -1
- package/dist/types/core/routing/validation.d.ts +1 -1
- package/dist/types/core/util.d.ts +11 -7
- package/dist/types/integrations/index.d.ts +6 -0
- package/dist/types/runtime/server/index.d.ts +1 -2
- package/dist/types/vite-plugin-astro/hmr.d.ts +1 -1
- package/dist/types/vite-plugin-astro/index.d.ts +1 -1
- package/dist/types/vite-plugin-astro-server/index.d.ts +1 -1
- package/dist/types/vite-plugin-build-css/index.d.ts +2 -1
- package/dist/types/vite-plugin-build-html/extract-assets.d.ts +1 -1
- package/dist/types/vite-plugin-build-html/index.d.ts +3 -3
- package/dist/types/vite-plugin-config-alias/index.d.ts +1 -1
- package/dist/types/vite-plugin-jsx/index.d.ts +1 -1
- package/dist/vite-plugin-astro/compile.js +12 -14
- package/dist/vite-plugin-astro/hmr.js +2 -2
- package/dist/vite-plugin-astro/index.js +21 -8
- package/dist/vite-plugin-astro/query.js +0 -0
- package/dist/vite-plugin-astro/styles.js +1 -1
- package/dist/vite-plugin-astro-postprocess/index.js +31 -34
- package/dist/vite-plugin-astro-server/index.js +50 -22
- package/dist/vite-plugin-build-css/index.js +47 -4
- package/dist/vite-plugin-build-css/resolve.js +0 -0
- package/dist/vite-plugin-build-html/add-rollup-input.js +0 -0
- package/dist/vite-plugin-build-html/extract-assets.js +0 -0
- package/dist/vite-plugin-build-html/index.js +22 -23
- package/dist/vite-plugin-build-html/util.js +0 -0
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-env/index.js +1 -1
- package/dist/vite-plugin-integrations-container/index.js +0 -0
- package/dist/vite-plugin-jsx/index.js +1 -1
- package/dist/vite-plugin-markdown/index.js +89 -18
- package/dist/vite-plugin-scripts/index.js +0 -0
- package/env.d.ts +1 -1
- package/package.json +13 -9
- package/dist/core/build/scan-based-build.js +0 -61
- package/dist/core/dev/util.js +0 -44
- package/dist/core/logger.js +0 -174
- package/dist/core/render/dev/error.js +0 -34
- package/dist/core/render/request.js +0 -23
- package/dist/core/render/sitemap.js +0 -18
- package/dist/types/core/build/scan-based-build.d.ts +0 -18
- package/dist/types/core/dev/util.d.ts +0 -9
- package/dist/types/core/render/dev/error.d.ts +0 -7
- package/dist/types/core/render/request.d.ts +0 -15
- package/dist/types/core/render/sitemap.d.ts +0 -2
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import type { AddressInfo } from 'net';
|
|
3
3
|
import type * as babel from '@babel/core';
|
|
4
4
|
import type * as vite from 'vite';
|
|
5
|
-
import
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { ShikiConfig, Plugin } from '@astrojs/markdown-remark';
|
|
6
7
|
import type { AstroConfigSchema } from '../core/config';
|
|
7
8
|
import type { AstroComponentFactory, Metadata } from '../runtime/server';
|
|
8
|
-
import type {
|
|
9
|
+
import type { ViteConfigWithSSR } from '../core/create-vite';
|
|
9
10
|
export type { SSRManifest } from '../core/app/types';
|
|
10
11
|
export interface AstroBuiltinProps {
|
|
11
12
|
'client:load'?: boolean;
|
|
@@ -25,18 +26,13 @@ export interface AstroComponentMetadata {
|
|
|
25
26
|
}
|
|
26
27
|
/** The flags supported by the Astro CLI */
|
|
27
28
|
export interface CLIFlags {
|
|
28
|
-
|
|
29
|
+
root?: string;
|
|
29
30
|
site?: string;
|
|
30
|
-
sitemap?: boolean;
|
|
31
31
|
host?: string | boolean;
|
|
32
|
-
hostname?: string;
|
|
33
32
|
port?: number;
|
|
34
33
|
config?: string;
|
|
35
|
-
/** @deprecated */
|
|
36
|
-
experimentalStaticBuild?: boolean;
|
|
37
34
|
experimentalSsr?: boolean;
|
|
38
35
|
experimentalIntegrations?: boolean;
|
|
39
|
-
legacyBuild?: boolean;
|
|
40
36
|
drafts?: boolean;
|
|
41
37
|
}
|
|
42
38
|
export interface BuildConfig {
|
|
@@ -50,24 +46,56 @@ export interface BuildConfig {
|
|
|
50
46
|
* Docs: https://docs.astro.build/reference/api-reference/#astro-global
|
|
51
47
|
*/
|
|
52
48
|
export interface AstroGlobal extends AstroGlobalPartial {
|
|
49
|
+
/** get the current canonical URL */
|
|
50
|
+
canonicalURL: URL;
|
|
51
|
+
/** get page params (dynamic pages only) */
|
|
52
|
+
params: Params;
|
|
53
53
|
/** set props for this astro component (along with default values) */
|
|
54
54
|
props: Record<string, number | string | any>;
|
|
55
55
|
/** get information about this page */
|
|
56
|
-
request:
|
|
56
|
+
request: Request;
|
|
57
57
|
/** see if slots are used */
|
|
58
58
|
slots: Record<string, true | undefined> & {
|
|
59
59
|
has(slotName: string): boolean;
|
|
60
|
-
render(slotName: string): Promise<string>;
|
|
60
|
+
render(slotName: string, args?: any[]): Promise<string>;
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
export interface AstroGlobalPartial {
|
|
64
|
-
fetchContent<T = any>(globStr: string): Promise<FetchContentResult<T>[]>;
|
|
65
64
|
/**
|
|
66
65
|
* @deprecated since version 0.24. See the {@link https://astro.build/deprecated/resolve upgrade guide} for more details.
|
|
67
66
|
*/
|
|
68
67
|
resolve: (path: string) => string;
|
|
68
|
+
/** @deprecated Use `Astro.glob()` instead. */
|
|
69
|
+
fetchContent(globStr: string): Promise<any[]>;
|
|
70
|
+
glob(globStr: `${any}.astro`): Promise<ComponentInstance[]>;
|
|
71
|
+
glob<T extends Record<string, any>>(globStr: `${any}.md`): Promise<MarkdownInstance<T>[]>;
|
|
72
|
+
glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
|
|
69
73
|
site: URL;
|
|
70
74
|
}
|
|
75
|
+
declare type ServerConfig = {
|
|
76
|
+
/**
|
|
77
|
+
* @name server.host
|
|
78
|
+
* @type {string | boolean}
|
|
79
|
+
* @default `false`
|
|
80
|
+
* @version 0.24.0
|
|
81
|
+
* @description
|
|
82
|
+
* Set which network IP addresses the dev server should listen on (i.e. non-localhost IPs).
|
|
83
|
+
* - `false` - do not expose on a network IP address
|
|
84
|
+
* - `true` - listen on all addresses, including LAN and public addresses
|
|
85
|
+
* - `[custom-address]` - expose on a network IP address at `[custom-address]`
|
|
86
|
+
*/
|
|
87
|
+
host?: string | boolean;
|
|
88
|
+
/**
|
|
89
|
+
* @name server.port
|
|
90
|
+
* @type {number}
|
|
91
|
+
* @default `3000`
|
|
92
|
+
* @description
|
|
93
|
+
* Set which port the dev server should listen on.
|
|
94
|
+
*
|
|
95
|
+
* If the given port is already in use, Astro will automatically try the next available port.
|
|
96
|
+
*/
|
|
97
|
+
port?: number;
|
|
98
|
+
};
|
|
71
99
|
/**
|
|
72
100
|
* Astro User Config
|
|
73
101
|
* Docs: https://docs.astro.build/reference/configuration-reference/
|
|
@@ -80,48 +108,48 @@ export interface AstroUserConfig {
|
|
|
80
108
|
*/
|
|
81
109
|
/**
|
|
82
110
|
* @docs
|
|
83
|
-
* @name
|
|
84
|
-
* @cli --
|
|
111
|
+
* @name root
|
|
112
|
+
* @cli --root
|
|
85
113
|
* @type {string}
|
|
86
114
|
* @default `"."` (current working directory)
|
|
87
115
|
* @summary Set the project root. The project root is the directory where your Astro project (and all `src`, `public` and `package.json` files) live.
|
|
88
116
|
* @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.js` file, since Astro needs to know your project root before it can locate your config file.
|
|
89
117
|
*
|
|
90
|
-
* If you provide a relative path (ex: `--
|
|
118
|
+
* If you provide a relative path (ex: `--root: './my-project'`) Astro will resolve it against your current working directory.
|
|
91
119
|
*
|
|
92
120
|
* #### Examples
|
|
93
121
|
*
|
|
94
122
|
* ```js
|
|
95
123
|
* {
|
|
96
|
-
*
|
|
124
|
+
* root: './my-project-directory'
|
|
97
125
|
* }
|
|
98
126
|
* ```
|
|
99
127
|
* ```bash
|
|
100
|
-
* $ astro build --
|
|
128
|
+
* $ astro build --root ./my-project-directory
|
|
101
129
|
* ```
|
|
102
130
|
*/
|
|
103
|
-
|
|
131
|
+
root?: string;
|
|
104
132
|
/**
|
|
105
133
|
* @docs
|
|
106
|
-
* @name
|
|
134
|
+
* @name srcDir
|
|
107
135
|
* @type {string}
|
|
108
|
-
* @default `"./
|
|
109
|
-
* @description Set the directory that
|
|
136
|
+
* @default `"./src"`
|
|
137
|
+
* @description Set the directory that Astro will read your site from.
|
|
110
138
|
*
|
|
111
139
|
* The value can be either an absolute file system path or a path relative to the project root.
|
|
112
140
|
*
|
|
113
141
|
* ```js
|
|
114
142
|
* {
|
|
115
|
-
*
|
|
143
|
+
* srcDir: './www'
|
|
116
144
|
* }
|
|
117
145
|
* ```
|
|
118
146
|
*/
|
|
119
|
-
|
|
147
|
+
srcDir?: string;
|
|
120
148
|
/**
|
|
121
149
|
* @docs
|
|
122
|
-
* @name
|
|
150
|
+
* @name publicDir
|
|
123
151
|
* @type {string}
|
|
124
|
-
* @default `"./
|
|
152
|
+
* @default `"./publicDir"`
|
|
125
153
|
* @description
|
|
126
154
|
* 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.
|
|
127
155
|
*
|
|
@@ -129,155 +157,90 @@ export interface AstroUserConfig {
|
|
|
129
157
|
*
|
|
130
158
|
* ```js
|
|
131
159
|
* {
|
|
132
|
-
*
|
|
160
|
+
* publicDir: './my-custom-publicDir-directory'
|
|
133
161
|
* }
|
|
134
162
|
* ```
|
|
135
163
|
*/
|
|
136
|
-
|
|
164
|
+
publicDir?: string;
|
|
137
165
|
/**
|
|
138
166
|
* @docs
|
|
139
|
-
* @name
|
|
140
|
-
* @type {
|
|
141
|
-
* @default `
|
|
142
|
-
* @description
|
|
143
|
-
* Add Integrations to your project to extend Astro.
|
|
144
|
-
*
|
|
145
|
-
* Integrations are your one-stop shop to add new frameworks (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks).
|
|
146
|
-
*
|
|
147
|
-
* Setting this configuration will disable Astro's default integration, so it is recommended to provide a renderer for every framework that you use:
|
|
167
|
+
* @name outDir
|
|
168
|
+
* @type {string}
|
|
169
|
+
* @default `"./outDir"`
|
|
170
|
+
* @description Set the directory that `astro build` writes your final build to.
|
|
148
171
|
*
|
|
149
|
-
*
|
|
172
|
+
* The value can be either an absolute file system path or a path relative to the project root.
|
|
150
173
|
*
|
|
151
174
|
* ```js
|
|
152
|
-
* import react from '@astrojs/react';
|
|
153
|
-
* import vue from '@astrojs/vue';
|
|
154
175
|
* {
|
|
155
|
-
*
|
|
156
|
-
* integrations: [react(), vue()]
|
|
176
|
+
* outDir: './my-custom-build-directory'
|
|
157
177
|
* }
|
|
158
178
|
* ```
|
|
159
179
|
*/
|
|
160
|
-
|
|
180
|
+
outDir?: string;
|
|
161
181
|
/**
|
|
162
182
|
* @docs
|
|
163
|
-
* @name
|
|
164
|
-
* @type {
|
|
165
|
-
* @default `undefined`
|
|
183
|
+
* @name site
|
|
184
|
+
* @type {string}
|
|
166
185
|
* @description
|
|
167
|
-
*
|
|
186
|
+
* 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.
|
|
187
|
+
*
|
|
188
|
+
* ```js
|
|
189
|
+
* {
|
|
190
|
+
* site: 'https://www.my-site.dev'
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
168
193
|
*/
|
|
169
|
-
|
|
170
|
-
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
|
|
171
|
-
renderers?: string[];
|
|
194
|
+
site?: string;
|
|
172
195
|
/**
|
|
173
196
|
* @docs
|
|
174
|
-
* @name
|
|
175
|
-
* @type {
|
|
176
|
-
* @see [Markdown guide](/en/guides/markdown-content/)
|
|
197
|
+
* @name base
|
|
198
|
+
* @type {string}
|
|
177
199
|
* @description
|
|
178
|
-
*
|
|
200
|
+
* The base path you're deploying to. Astro will match this pathname during development so that your development experience matches your build environment as closely as possible. In the example below, `astro dev` will start your server at `/docs`.
|
|
179
201
|
*
|
|
180
202
|
* ```js
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
203
|
+
* {
|
|
204
|
+
* base: '/docs'
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
base?: string;
|
|
209
|
+
/**
|
|
210
|
+
* @docs
|
|
211
|
+
* @name trailingSlash
|
|
212
|
+
* @type {('always' | 'never' | 'ignore')}
|
|
213
|
+
* @default `'always'`
|
|
214
|
+
* @see buildOptions.pageUrlFormat
|
|
215
|
+
* @description
|
|
184
216
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* // The Remark parser to parse Markdown content
|
|
190
|
-
* astroRemark,
|
|
191
|
-
* {
|
|
192
|
-
* // Add a Remark plugin to your project.
|
|
193
|
-
* remarkPlugins: ["remark-code-titles"],
|
|
217
|
+
* Set the route matching behavior of the dev server. Choose from the following options:
|
|
218
|
+
* - `'always'` - Only match URLs that include a trailing slash (ex: "/foo/")
|
|
219
|
+
* - `'never'` - Never match URLs that include a trailing slash (ex: "/foo")
|
|
220
|
+
* - `'ignore'` - Match URLs regardless of whether a trailing "/" exists
|
|
194
221
|
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* });
|
|
222
|
+
* Use this configuration option if your production host has strict handling of how trailing slashes work or do not work.
|
|
223
|
+
*
|
|
224
|
+
* 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.
|
|
225
|
+
*
|
|
226
|
+
* ```js
|
|
227
|
+
* {
|
|
228
|
+
* // Example: Require a trailing slash during development
|
|
229
|
+
* trailingSlash: 'always'
|
|
230
|
+
* }
|
|
205
231
|
* ```
|
|
206
232
|
*/
|
|
207
|
-
|
|
208
|
-
render?: MarkdownRenderOptions;
|
|
209
|
-
};
|
|
233
|
+
trailingSlash?: 'always' | 'never' | 'ignore';
|
|
210
234
|
/**
|
|
211
235
|
* @docs
|
|
212
236
|
* @kind heading
|
|
213
237
|
* @name Build Options
|
|
214
238
|
*/
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* @docs
|
|
218
|
-
* @name buildOptions.site
|
|
219
|
-
* @type {string}
|
|
220
|
-
* @description
|
|
221
|
-
* 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.
|
|
222
|
-
*
|
|
223
|
-
* Astro will match the site pathname during development so that your development experience matches your build environment as closely as possible. In the example below, `astro dev` will start your server at `http://localhost:3000/docs`.
|
|
224
|
-
*
|
|
225
|
-
* ```js
|
|
226
|
-
* {
|
|
227
|
-
* buildOptions: {
|
|
228
|
-
* // Example: Tell Astro the final URL of your deployed website.
|
|
229
|
-
* site: 'https://www.my-site.dev/docs'
|
|
230
|
-
* }
|
|
231
|
-
* }
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
site?: string;
|
|
235
|
-
/**
|
|
236
|
-
* @docs
|
|
237
|
-
* @name buildOptions.sitemap
|
|
238
|
-
* @type {boolean}
|
|
239
|
-
* @default `true`
|
|
240
|
-
* @description
|
|
241
|
-
* Generate a sitemap for your build. Set to false to disable.
|
|
242
|
-
*
|
|
243
|
-
* Astro will automatically generate a sitemap including all generated pages on your site. If you need more control over your sitemap, consider generating it yourself using a [Non-HTML Page](/en/core-concepts/astro-pages/#non-html-pages).
|
|
244
|
-
*
|
|
245
|
-
* ```js
|
|
246
|
-
* {
|
|
247
|
-
* buildOptions: {
|
|
248
|
-
* // Example: Disable automatic sitemap generation
|
|
249
|
-
* sitemap: false
|
|
250
|
-
* }
|
|
251
|
-
* }
|
|
252
|
-
* ```
|
|
253
|
-
*/
|
|
254
|
-
sitemap?: boolean;
|
|
255
|
-
/**
|
|
256
|
-
* @docs
|
|
257
|
-
* @name buildOptions.sitemapFilter
|
|
258
|
-
* @typeraw {(page: string) => boolean}
|
|
259
|
-
* @see buildOptions.sitemap
|
|
260
|
-
* @description
|
|
261
|
-
* By default, all pages are included in your generated sitemap.
|
|
262
|
-
* You can filter included pages by URL using `buildOptions.sitemapFilter`.
|
|
263
|
-
*
|
|
264
|
-
* The `page` function parameter is the full URL of your rendered page, including your `buildOptions.site` domain.
|
|
265
|
-
* Return `true` to include a page in your sitemap, and `false` to remove it.
|
|
266
|
-
*
|
|
267
|
-
* ```js
|
|
268
|
-
* {
|
|
269
|
-
* buildOptions: {
|
|
270
|
-
* sitemap: true
|
|
271
|
-
* sitemapFilter: (page) => page !== 'http://example.com/secret-page')
|
|
272
|
-
* }
|
|
273
|
-
* }
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
sitemapFilter?: (page: string) => boolean;
|
|
239
|
+
build?: {
|
|
277
240
|
/**
|
|
278
241
|
* @docs
|
|
279
|
-
* @name
|
|
280
|
-
* @
|
|
242
|
+
* @name build.format
|
|
243
|
+
* @typeraw {('file' | 'directory')}
|
|
281
244
|
* @default `'directory'`
|
|
282
245
|
* @description
|
|
283
246
|
* Control the output file format of each page.
|
|
@@ -286,17 +249,72 @@ export interface AstroUserConfig {
|
|
|
286
249
|
*
|
|
287
250
|
* ```js
|
|
288
251
|
* {
|
|
289
|
-
*
|
|
252
|
+
* build: {
|
|
290
253
|
* // Example: Generate `page.html` instead of `page/index.html` during build.
|
|
291
|
-
*
|
|
254
|
+
* format: 'file'
|
|
292
255
|
* }
|
|
293
256
|
* }
|
|
294
257
|
* ```
|
|
295
258
|
*/
|
|
296
|
-
|
|
259
|
+
format?: 'file' | 'directory';
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* @docs
|
|
263
|
+
* @kind heading
|
|
264
|
+
* @name Server Options
|
|
265
|
+
* @description
|
|
266
|
+
*
|
|
267
|
+
* Customize the Astro dev server, used by both `astro dev` and `astro serve`.
|
|
268
|
+
*
|
|
269
|
+
* ```js
|
|
270
|
+
* {
|
|
271
|
+
* server: {port: 1234, host: true}
|
|
272
|
+
* }
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* To set different configuration based on the command run ("dev", "preview") a function can also be passed to this configuration option.
|
|
276
|
+
*
|
|
277
|
+
* ```js
|
|
278
|
+
* {
|
|
279
|
+
* // Example: Use the function syntax to customize based on command
|
|
280
|
+
* server: (command) => ({port: command === 'dev' ? 3000 : 4000})
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
/**
|
|
285
|
+
* @docs
|
|
286
|
+
* @name server.host
|
|
287
|
+
* @type {string | boolean}
|
|
288
|
+
* @default `false`
|
|
289
|
+
* @version 0.24.0
|
|
290
|
+
* @description
|
|
291
|
+
* Set which network IP addresses the dev server should listen on (i.e. non-localhost IPs).
|
|
292
|
+
* - `false` - do not expose on a network IP address
|
|
293
|
+
* - `true` - listen on all addresses, including LAN and public addresses
|
|
294
|
+
* - `[custom-address]` - expose on a network IP address at `[custom-address]`
|
|
295
|
+
*/
|
|
296
|
+
/**
|
|
297
|
+
* @docs
|
|
298
|
+
* @name server.port
|
|
299
|
+
* @type {number}
|
|
300
|
+
* @default `3000`
|
|
301
|
+
* @description
|
|
302
|
+
* Set which port the dev server should listen on.
|
|
303
|
+
*
|
|
304
|
+
* If the given port is already in use, Astro will automatically try the next available port.
|
|
305
|
+
*/
|
|
306
|
+
server?: ServerConfig | ((options: {
|
|
307
|
+
command: 'dev' | 'preview';
|
|
308
|
+
}) => ServerConfig);
|
|
309
|
+
/**
|
|
310
|
+
* @docs
|
|
311
|
+
* @kind heading
|
|
312
|
+
* @name Markdown Options
|
|
313
|
+
*/
|
|
314
|
+
markdown?: {
|
|
297
315
|
/**
|
|
298
316
|
* @docs
|
|
299
|
-
* @name
|
|
317
|
+
* @name markdown.drafts
|
|
300
318
|
* @type {boolean}
|
|
301
319
|
* @default `false`
|
|
302
320
|
* @description
|
|
@@ -306,110 +324,114 @@ export interface AstroUserConfig {
|
|
|
306
324
|
*
|
|
307
325
|
* ```js
|
|
308
326
|
* {
|
|
309
|
-
*
|
|
327
|
+
* markdown: {
|
|
310
328
|
* // Example: Include all drafts in your final build
|
|
311
|
-
*
|
|
329
|
+
* drafts: true,
|
|
312
330
|
* }
|
|
313
331
|
* }
|
|
314
332
|
* ```
|
|
315
333
|
*/
|
|
316
334
|
drafts?: boolean;
|
|
317
|
-
/**
|
|
318
|
-
* Enables "legacy build mode" for compatibility with older Astro versions.
|
|
319
|
-
* Default: false
|
|
320
|
-
*/
|
|
321
|
-
legacyBuild?: boolean;
|
|
322
|
-
/**
|
|
323
|
-
* @deprecated
|
|
324
|
-
* Experimental: Enables "static build mode" for faster builds.
|
|
325
|
-
* Default: true
|
|
326
|
-
*/
|
|
327
|
-
experimentalStaticBuild?: boolean;
|
|
328
|
-
/**
|
|
329
|
-
* Enable a build for SSR support.
|
|
330
|
-
* Default: false
|
|
331
|
-
*/
|
|
332
|
-
experimentalSsr?: boolean;
|
|
333
|
-
};
|
|
334
|
-
/**
|
|
335
|
-
* @docs
|
|
336
|
-
* @kind heading
|
|
337
|
-
* @name Dev Options
|
|
338
|
-
*/
|
|
339
|
-
devOptions?: {
|
|
340
335
|
/**
|
|
341
336
|
* @docs
|
|
342
|
-
* @name
|
|
343
|
-
* @type {
|
|
344
|
-
* @default `false`
|
|
345
|
-
* @version 0.24.0
|
|
337
|
+
* @name markdown.shikiConfig
|
|
338
|
+
* @type {ShikiConfig}
|
|
346
339
|
* @description
|
|
347
|
-
*
|
|
348
|
-
* - `false` - do not expose on a network IP address
|
|
349
|
-
* - `true` - listen on all addresses, including LAN and public addresses
|
|
350
|
-
* - `[custom-address]` - expose on a network IP address at `[custom-address]`
|
|
340
|
+
* Shiki configuration options. See [the markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage.
|
|
351
341
|
*/
|
|
352
|
-
|
|
342
|
+
shikiConfig?: ShikiConfig;
|
|
353
343
|
/**
|
|
354
344
|
* @docs
|
|
355
|
-
* @name
|
|
356
|
-
* @type {
|
|
357
|
-
* @default `
|
|
358
|
-
* @deprecated Use `host` instead
|
|
345
|
+
* @name markdown.syntaxHighlight
|
|
346
|
+
* @type {'shiki' | 'prism' | false}
|
|
347
|
+
* @default `shiki`
|
|
359
348
|
* @description
|
|
360
|
-
*
|
|
349
|
+
* Which syntax highlighter to use, if any.
|
|
350
|
+
* - `shiki` - use the [Shiki](https://github.com/shikijs/shiki) highlighter
|
|
351
|
+
* - `prism` - use the [Prism](https://prismjs.com/) highlighter
|
|
352
|
+
* - `false` - do not apply syntax highlighting.
|
|
361
353
|
*
|
|
362
|
-
*
|
|
354
|
+
* ```js
|
|
355
|
+
* {
|
|
356
|
+
* markdown: {
|
|
357
|
+
* // Example: Switch to use prism for syntax highlighting in Markdown
|
|
358
|
+
* syntaxHighlight: 'prism',
|
|
359
|
+
* }
|
|
360
|
+
* }
|
|
361
|
+
* ```
|
|
363
362
|
*/
|
|
364
|
-
|
|
363
|
+
syntaxHighlight?: 'shiki' | 'prism' | false;
|
|
365
364
|
/**
|
|
366
365
|
* @docs
|
|
367
|
-
* @name
|
|
368
|
-
* @type {
|
|
369
|
-
* @default `3000`
|
|
366
|
+
* @name markdown.remarkPlugins
|
|
367
|
+
* @type {Plugin[]}
|
|
370
368
|
* @description
|
|
371
|
-
*
|
|
369
|
+
* Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built.
|
|
370
|
+
*
|
|
371
|
+
* **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
|
|
372
372
|
*
|
|
373
|
-
*
|
|
373
|
+
* ```js
|
|
374
|
+
* {
|
|
375
|
+
* markdown: {
|
|
376
|
+
* // Example: The default set of remark plugins used by Astro
|
|
377
|
+
* remarkPlugins: ['remark-code-titles', ['rehype-autolink-headings', { behavior: 'prepend' }]],
|
|
378
|
+
* },
|
|
379
|
+
* };
|
|
380
|
+
* ```
|
|
374
381
|
*/
|
|
375
|
-
|
|
382
|
+
remarkPlugins?: Plugin[];
|
|
376
383
|
/**
|
|
377
384
|
* @docs
|
|
378
|
-
* @name
|
|
379
|
-
* @type {
|
|
380
|
-
* @default `'always'`
|
|
381
|
-
* @see buildOptions.pageUrlFormat
|
|
385
|
+
* @name markdown.rehypePlugins
|
|
386
|
+
* @type {Plugin[]}
|
|
382
387
|
* @description
|
|
388
|
+
* Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built.
|
|
383
389
|
*
|
|
384
|
-
*
|
|
385
|
-
* - 'always' - Only match URLs that include a trailing slash (ex: "/foo/")
|
|
386
|
-
* - 'never' - Never match URLs that include a trailing slash (ex: "/foo")
|
|
387
|
-
* - 'ignore' - Match URLs regardless of whether a trailing "/" exists
|
|
388
|
-
*
|
|
389
|
-
* Use this configuration option if your production host has strict handling of how trailing slashes work or do not work.
|
|
390
|
-
*
|
|
391
|
-
* 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.
|
|
390
|
+
* **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
|
|
392
391
|
*
|
|
393
392
|
* ```js
|
|
394
393
|
* {
|
|
395
|
-
*
|
|
396
|
-
* // Example:
|
|
397
|
-
*
|
|
398
|
-
* }
|
|
399
|
-
* }
|
|
394
|
+
* markdown: {
|
|
395
|
+
* // Example: The default set of rehype plugins used by Astro
|
|
396
|
+
* rehypePlugins: [['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'],
|
|
397
|
+
* },
|
|
398
|
+
* };
|
|
400
399
|
* ```
|
|
401
400
|
*/
|
|
402
|
-
|
|
401
|
+
rehypePlugins?: Plugin[];
|
|
403
402
|
};
|
|
404
403
|
/**
|
|
405
|
-
*
|
|
406
|
-
*
|
|
404
|
+
* @name adapter
|
|
405
|
+
* @type {AstroIntegration}
|
|
406
|
+
* @default `undefined`
|
|
407
|
+
* @description
|
|
408
|
+
* Add an adapter to build for SSR (server-side rendering). An adapter makes it easy to connect a deployed Astro app to a hosting provider or runtime environment.
|
|
407
409
|
*/
|
|
408
|
-
|
|
410
|
+
adapter?: AstroIntegration;
|
|
411
|
+
/**
|
|
412
|
+
* @docs
|
|
413
|
+
* @kind heading
|
|
414
|
+
* @name Integrations
|
|
415
|
+
* @description
|
|
416
|
+
*
|
|
417
|
+
* 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 and Turbolinks).
|
|
418
|
+
*
|
|
419
|
+
* Read our [Integrations Guide](/en/guides/integrations-guide/) for help getting started with Astro Integrations.
|
|
420
|
+
*
|
|
421
|
+
* ```js
|
|
422
|
+
* import react from '@astrojs/react';
|
|
423
|
+
* import tailwind from '@astrojs/tailwind';
|
|
424
|
+
* {
|
|
425
|
+
* // Example: Add React + Tailwind support to Astro
|
|
426
|
+
* integrations: [react(), tailwind()]
|
|
427
|
+
* }
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
integrations?: Array<AstroIntegration | AstroIntegration[]>;
|
|
409
431
|
/**
|
|
410
432
|
* @docs
|
|
411
|
-
* @
|
|
412
|
-
* @
|
|
433
|
+
* @kind heading
|
|
434
|
+
* @name Vite
|
|
413
435
|
* @description
|
|
414
436
|
*
|
|
415
437
|
* Pass additional configuration options to Vite. Useful when Astro doesn't support some advanced configuration that you may need.
|
|
@@ -421,9 +443,9 @@ export interface AstroUserConfig {
|
|
|
421
443
|
* ```js
|
|
422
444
|
* {
|
|
423
445
|
* vite: {
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
446
|
+
* ssr: {
|
|
447
|
+
* // Example: Force a broken package to skip SSR processing, if needed
|
|
448
|
+
* external: ['broken-npm-package'],
|
|
427
449
|
* }
|
|
428
450
|
* }
|
|
429
451
|
* }
|
|
@@ -433,7 +455,7 @@ export interface AstroUserConfig {
|
|
|
433
455
|
* {
|
|
434
456
|
* vite: {
|
|
435
457
|
* // Example: Add custom vite plugins directly to your Astro project
|
|
436
|
-
*
|
|
458
|
+
* plugins: [myPlugin()],
|
|
437
459
|
* }
|
|
438
460
|
* }
|
|
439
461
|
* ```
|
|
@@ -441,6 +463,40 @@ export interface AstroUserConfig {
|
|
|
441
463
|
vite?: vite.UserConfig & {
|
|
442
464
|
ssr?: vite.SSROptions;
|
|
443
465
|
};
|
|
466
|
+
experimental?: {
|
|
467
|
+
/**
|
|
468
|
+
* Enable experimental support for 3rd-party integrations.
|
|
469
|
+
* Default: false
|
|
470
|
+
*/
|
|
471
|
+
integrations?: boolean;
|
|
472
|
+
/**
|
|
473
|
+
* Enable a build for SSR support.
|
|
474
|
+
* Default: false
|
|
475
|
+
*/
|
|
476
|
+
ssr?: boolean;
|
|
477
|
+
};
|
|
478
|
+
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
|
|
479
|
+
renderers?: never;
|
|
480
|
+
/** @deprecated `projectRoot` has been renamed to `root` */
|
|
481
|
+
projectRoot?: never;
|
|
482
|
+
/** @deprecated `src` has been renamed to `srcDir` */
|
|
483
|
+
src?: never;
|
|
484
|
+
/** @deprecated `pages` has been removed. It is no longer configurable. */
|
|
485
|
+
pages?: never;
|
|
486
|
+
/** @deprecated `public` has been renamed to `publicDir` */
|
|
487
|
+
public?: never;
|
|
488
|
+
/** @deprecated `dist` has been renamed to `outDir` */
|
|
489
|
+
dist?: never;
|
|
490
|
+
/** @deprecated `styleOptions` has been renamed to `style` */
|
|
491
|
+
styleOptions?: never;
|
|
492
|
+
/** @deprecated `markdownOptions` has been renamed to `markdown` */
|
|
493
|
+
markdownOptions?: never;
|
|
494
|
+
/** @deprecated `buildOptions` has been renamed to `build` */
|
|
495
|
+
buildOptions?: never;
|
|
496
|
+
/** @deprecated `devOptions` has been renamed to `server` */
|
|
497
|
+
devOptions?: never;
|
|
498
|
+
/** @deprecated `experimentalIntegrations` has been renamed to `experimental: { integrations: true }` */
|
|
499
|
+
experimentalIntegrations?: never;
|
|
444
500
|
}
|
|
445
501
|
/**
|
|
446
502
|
* IDs for different stages of JS script injection:
|
|
@@ -474,19 +530,17 @@ export interface ComponentInstance {
|
|
|
474
530
|
css?: string[];
|
|
475
531
|
getStaticPaths?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
|
|
476
532
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
url: string;
|
|
489
|
-
};
|
|
533
|
+
export interface MarkdownInstance<T extends Record<string, any>> {
|
|
534
|
+
frontmatter: T;
|
|
535
|
+
file: string;
|
|
536
|
+
url: string | undefined;
|
|
537
|
+
Content: AstroComponentFactory;
|
|
538
|
+
getHeaders(): Promise<{
|
|
539
|
+
depth: number;
|
|
540
|
+
slug: string;
|
|
541
|
+
text: string;
|
|
542
|
+
}[]>;
|
|
543
|
+
}
|
|
490
544
|
export declare type GetHydrateCallback = () => Promise<(element: Element, innerHTML: string | null) => void>;
|
|
491
545
|
/**
|
|
492
546
|
* getStaticPaths() options
|
|
@@ -588,7 +642,7 @@ export interface EndpointOutput<Output extends Body = Body> {
|
|
|
588
642
|
body: Output;
|
|
589
643
|
}
|
|
590
644
|
export interface EndpointHandler {
|
|
591
|
-
[method: string]: (params: any, request:
|
|
645
|
+
[method: string]: (params: any, request: Request) => EndpointOutput | Response;
|
|
592
646
|
}
|
|
593
647
|
export interface AstroRenderer {
|
|
594
648
|
/** Name of the renderer. */
|
|
@@ -636,6 +690,10 @@ export interface AstroIntegration {
|
|
|
636
690
|
'astro:build:start'?: (options: {
|
|
637
691
|
buildConfig: BuildConfig;
|
|
638
692
|
}) => void | Promise<void>;
|
|
693
|
+
'astro:build:setup'?: (options: {
|
|
694
|
+
vite: ViteConfigWithSSR;
|
|
695
|
+
target: 'client' | 'server';
|
|
696
|
+
}) => void;
|
|
639
697
|
'astro:build:done'?: (options: {
|
|
640
698
|
pages: {
|
|
641
699
|
pathname: string;
|