/
astro.ts
1961 lines (1838 loc) · 54 KB
/
astro.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import type {
MarkdownHeading,
MarkdownMetadata,
MarkdownRenderingResult,
RehypePlugins,
RemarkPlugins,
RemarkRehype,
ShikiConfig,
} from '@astrojs/markdown-remark';
import type * as babel from '@babel/core';
import type { OutgoingHttpHeaders } from 'http';
import type { AddressInfo } from 'net';
import type * as rollup from 'rollup';
import type { TsConfigJson } from 'tsconfig-resolver';
import type * as vite from 'vite';
import type { z } from 'zod';
import type { SerializedSSRManifest } from '../core/app/types';
import type { PageBuildData } from '../core/build/types';
import type { AstroConfigSchema } from '../core/config';
import type { AstroTimer } from '../core/config/timer';
import type { AstroCookies } from '../core/cookies';
import type { LogOptions } from '../core/logger/core';
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
export type {
MarkdownHeading,
MarkdownMetadata,
MarkdownRenderingResult,
RehypePlugins,
RemarkPlugins,
ShikiConfig,
} from '@astrojs/markdown-remark';
export type {
ExternalImageService,
ImageService,
LocalImageService,
} from '../assets/services/service';
export type {
GetImageResult,
ImageInputFormat,
ImageMetadata,
ImageOutputFormat,
ImageQuality,
ImageQualityPreset,
ImageTransform,
} from '../assets/types';
export type { SSRManifest } from '../core/app/types';
export type { AstroCookies } from '../core/cookies';
export interface AstroBuiltinProps {
'client:load'?: boolean;
'client:idle'?: boolean;
'client:media'?: string;
'client:visible'?: boolean;
'client:only'?: boolean | string;
}
// Allow users to extend this for astro-jsx.d.ts
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AstroClientDirectives {}
export interface AstroBuiltinAttributes {
'class:list'?:
| Record<string, boolean>
| Record<any, any>
| Iterable<string>
| Iterable<any>
| string;
'set:html'?: any;
'set:text'?: any;
'is:raw'?: boolean;
}
export interface AstroDefineVarsAttribute {
'define:vars'?: any;
}
export interface AstroStyleAttributes {
/** @deprecated Use `is:global` instead */
global?: boolean;
'is:global'?: boolean;
'is:inline'?: boolean;
}
export interface AstroScriptAttributes {
/** @deprecated Hoist is now the default behavior */
hoist?: boolean;
'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;
drafts?: boolean;
open?: boolean;
experimentalAssets?: boolean;
experimentalMiddleware?: boolean;
}
export interface BuildConfig {
/**
* @deprecated Use config.build.client instead.
*/
client: URL;
/**
* @deprecated Use config.build.server instead.
*/
server: URL;
/**
* @deprecated Use config.build.serverEntry instead.
*/
serverEntry: string;
}
/**
* Astro global available in all contexts in .astro files
*
* [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global)
*/
export interface AstroGlobal<Props extends Record<string, any> = Record<string, any>>
extends AstroGlobalPartial,
AstroSharedContext<Props> {
/**
* 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;
* ---
* <h1>{id}</h1>
* ```
*
* [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/core-concepts/astro-components/#component-props)
*/
props: AstroSharedContext<Props>['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/#astroredirect)
*/
redirect: AstroSharedContext['redirect'];
/**
* The <Astro.self /> element allows a component to reference itself recursively.
*
* [Astro reference](https://docs.astro.build/en/guides/api-reference/#astroself)
*/
self: AstroComponentFactory;
/** Utility functions for modifying an Astro component’s slotted children
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
*/
slots: Record<string, true | undefined> & {
/**
* 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')
* }
* ---
* <Fragment set:html={html} />
* ```
*
* 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
* <Component>
* {(hello, world) => <div>{hello}, {world}!</div>}
* </Component>
* ```
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
*/
render(slotName: string, args?: any[]): Promise<string>;
};
}
/** 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<AstroInstance[]>;
glob<T extends Record<string, any>>(
globStr: `${any}${MarkdowFileExtension}`
): Promise<MarkdownInstance<T>[]>;
glob<T extends Record<string, any>>(globStr: `${any}.mdx`): Promise<MDXInstance<T>[]>;
glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
/**
* 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 `<meta name="generator" content={Astro.generator} />` 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 `3000`
* @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;
};
export interface ViteUserConfig extends vite.UserConfig {
ssr?: vite.SSROptions;
}
export interface ImageServiceConfig {
// eslint-disable-next-line @typescript-eslint/ban-types
entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | (string & {});
config?: Record<string, any>;
}
/**
* Astro User Config
* Docs: https://docs.astro.build/reference/configuration-reference/
*/
export interface AstroUserConfig {
/**
* @docs
* @kind heading
* @name Top-Level Options
*/
/**
* @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 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 compressHTML
* @type {boolean}
* @default `false`
* @description
* This is an option to minify your HTML output and reduce the size of your HTML files. When enabled, 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 enable this, set the `compressHTML` flag to `true`.
*
* ```js
* {
* compressHTML: true
* }
* ```
*/
compressHTML?: boolean;
/**
* @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`.
*
* ```astro
* <a href="/docs/about/">About</a>
* <img src=`${import.meta.env.BASE_URL}/image.png`>
* ```
*/
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 scopedStyleStrategy
* @type {('where' | 'class')}
* @default `'where'`
* @version 2.4
* @description
*
* Specify the strategy used for scoping styles within Astro components. Choose from:
* - `'where'` - Use `:where` selectors, causing no specifity increase.
* - `'class'` - Use class-based selectors, causing a +1 specifity 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 specifity, but requires that you use higher-specifity selectors, layers, and other tools to control which selectors are applied.
*/
scopedStyleStrategy?: 'where' | 'class';
/**
* @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-ssredge), [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/functions';
* {
* // Example: Build for Netlify serverless deployment
* adapter: netlify(),
* }
* ```
*/
adapter?: AstroIntegration;
/**
* @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 deploy 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
* @kind heading
* @name Build Options
*/
build?: {
/**
* @docs
* @name build.format
* @typeraw {('file' | 'directory')}
* @default `'directory'`
* @description
* Control the output file format of each page.
* - If 'file', Astro will generate an HTML file (ex: "/foo.html") for each page.
* - If 'directory', Astro will generate a directory with a nested `index.html` file (ex: "/foo/index.html") for each page.
*
* ```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.
*/
format?: 'file' | 'directory';
/**
* @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
* @kind heading
* @name Server Options
* @description
*
* Customize the Astro dev server, used by both `astro dev` and `astro preview`.
*
* ```js
* {
* server: { port: 1234, host: true}
* }
* ```
*
* To set different configuration based on the command run ("dev", "preview") a function can also be passed to this configuration option.
*
* ```js
* {
* // Example: Use the function syntax to customize based on command
* server: (command) => ({ port: command === 'dev' ? 3000 : 4000 })
* }
* ```
*/
/**
* @docs
* @name server.host
* @type {string | boolean}
* @default `false`
* @version 0.24.0
* @description
* Set which network IP addresses the 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]` (ex: `192.168.0.1`)
*/
/**
* @docs
* @name server.port
* @type {number}
* @default `3000`
* @description
* Set which port the server should listen on.
*
* If the given port is already in use, Astro will automatically try the next available port.
*
* ```js
* {
* server: { port: 8080 }
* }
* ```
*/
/**
* @docs
* @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`.
*/
server?: ServerConfig | ((options: { command: 'dev' | 'preview' }) => ServerConfig);
/**
* @docs
* @kind heading
* @name Image options
*/
image?: {
/**
* @docs
* @name image.service (Experimental)
* @type {{entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | string, config: Record<string, any>}}
* @default `{entrypoint: 'astro/assets/services/squoosh', config?: {}}`
* @version 2.1.0
* @description
* Set which image service is used for Astro’s experimental assets support.
*
* The value should be an object with an entrypoint for the image service to use and optionally, a config object to pass to the service.
*
* The service entrypoint can be either one of the included services, or a third-party package.
*
* ```js
* {
* image: {
* // Example: Enable the Sharp-based image service
* service: { entrypoint: 'astro/assets/services/sharp' },
* },
* }
* ```
*/
service: ImageServiceConfig;
};
/**
* @docs
* @kind heading
* @name Markdown Options
*/
markdown?: {
/**
* @docs
* @name markdown.drafts
* @type {boolean}
* @default `false`
* @description
* Control whether Markdown draft pages should be included in the build.
*
* A Markdown page is considered a draft if it includes `draft: true` in its frontmatter. Draft pages are always included & visible during development (`astro dev`) but by default they will not be included in your final build.
*
* ```js
* {
* markdown: {
* // Example: Include all drafts in your final build
* drafts: true,
* }
* }
* ```
*/
drafts?: boolean;
/**
* @docs
* @name markdown.shikiConfig
* @typeraw {Partial<ShikiConfig>}
* @description
* Shiki configuration options. See [the Markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage.
*/
shikiConfig?: Partial<ShikiConfig>;
/**
* @docs
* @name markdown.syntaxHighlight
* @type {'shiki' | 'prism' | false}
* @default `shiki`
* @description
* Which syntax highlighter to use, if any.
* - `shiki` - use the [Shiki](https://github.com/shikijs/shiki) highlighter
* - `prism` - use the [Prism](https://prismjs.com/) highlighter
* - `false` - do not apply syntax highlighting.
*
* ```js
* {
* markdown: {
* // Example: Switch to use prism for syntax highlighting in Markdown
* syntaxHighlight: 'prism',
* }
* }
* ```
*/
syntaxHighlight?: 'shiki' | 'prism' | false;
/**
* @docs
* @name markdown.remarkPlugins
* @type {RemarkPlugins}
* @description
* Pass [remark plugins](https://github.com/remarkjs/remark) to customize how your Markdown is built. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
*
* ```js
* import remarkToc from 'remark-toc';
* {
* markdown: {
* remarkPlugins: [remarkToc]
* }
* }
* ```
*/
remarkPlugins?: RemarkPlugins;
/**
* @docs
* @name markdown.rehypePlugins
* @type {RehypePlugins}
* @description
* Pass [rehype plugins](https://github.com/remarkjs/remark-rehype) to customize how your Markdown's output HTML is processed. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
*
* ```js
* import rehypeMinifyHtml from 'rehype-minify';
* {
* markdown: {
* rehypePlugins: [rehypeMinifyHtml]
* }
* }
* ```
*/
rehypePlugins?: RehypePlugins;
/**
* @docs
* @name markdown.gfm
* @type {boolean}
* @default `true`
* @version 2.0.0
* @description
* Astro uses [GitHub-flavored Markdown](https://github.com/remarkjs/remark-gfm) by default. To disable this, set the `gfm` flag to `false`:
*
* ```js
* {
* markdown: {
* gfm: false,
* }
* }
* ```
*/
gfm?: boolean;
/**
* @docs
* @name markdown.smartypants
* @type {boolean}
* @default `true`
* @version 2.0.0
* @description
* Astro uses the [SmartyPants formatter](https://daringfireball.net/projects/smartypants/) by default. To disable this, set the `smartypants` flag to `false`:
*
* ```js
* {
* markdown: {
* smartypants: false,
* }
* }
* ```
*/
smartypants?: boolean;
/**
* @docs
* @name markdown.remarkRehype
* @type {RemarkRehype}
* @description
* Pass options to [remark-rehype](https://github.com/remarkjs/remark-rehype#api).
*
* ```js
* {
* markdown: {
* // Example: Translate the footnotes text to another language, here are the default English values
* remarkRehype: { footnoteLabel: "Footnotes", footnoteBackLabel: "Back to content"},
* },
* };
* ```
*/
remarkRehype?: RemarkRehype;
};
/**
* @docs
* @kind heading
* @name Integrations
* @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 and Turbolinks).
*
* 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()]
* }
* ```
*/