astro 1.0.8 → 1.1.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.
Files changed (163) hide show
  1. package/astro-jsx.d.ts +5 -5
  2. package/client-base.d.ts +1 -1
  3. package/dist/{types/@types → @types}/astro.d.ts +88 -27
  4. package/dist/{types/cli → cli}/check/index.d.ts +0 -0
  5. package/dist/{types/cli → cli}/check/print.d.ts +0 -0
  6. package/dist/{types/cli → cli}/index.d.ts +0 -0
  7. package/dist/{types/cli → cli}/open.d.ts +0 -0
  8. package/dist/{types/cli → cli}/telemetry.d.ts +0 -0
  9. package/dist/{types/core → core}/add/babel.d.ts +0 -0
  10. package/dist/{types/core → core}/add/imports.d.ts +0 -0
  11. package/dist/{types/core → core}/add/index.d.ts +0 -0
  12. package/dist/{types/core → core}/add/wrapper.d.ts +0 -0
  13. package/dist/{types/core → core}/app/common.d.ts +0 -0
  14. package/dist/{types/core → core}/app/index.d.ts +0 -0
  15. package/dist/{types/core → core}/app/node.d.ts +0 -0
  16. package/dist/{types/core → core}/app/types.d.ts +0 -0
  17. package/dist/{types/core → core}/build/add-rollup-input.d.ts +0 -0
  18. package/dist/{types/core → core}/build/common.d.ts +0 -0
  19. package/dist/{types/core → core}/build/generate.d.ts +0 -0
  20. package/dist/core/build/generate.js +22 -1
  21. package/dist/{types/core → core}/build/graph.d.ts +1 -0
  22. package/dist/core/build/graph.js +5 -2
  23. package/dist/{types/core → core}/build/index.d.ts +0 -0
  24. package/dist/{types/core → core}/build/internal.d.ts +2 -0
  25. package/dist/core/build/internal.js +16 -3
  26. package/dist/{types/core → core}/build/page-data.d.ts +0 -0
  27. package/dist/{types/core → core}/build/static-build.d.ts +0 -0
  28. package/dist/core/build/static-build.js +4 -2
  29. package/dist/{types/core → core}/build/types.d.ts +0 -0
  30. package/dist/{types/core → core}/build/util.d.ts +0 -0
  31. package/dist/{types/core → core}/build/vite-plugin-analyzer.d.ts +0 -0
  32. package/dist/{types/core → core}/build/vite-plugin-css.d.ts +0 -0
  33. package/dist/core/build/vite-plugin-css.js +53 -15
  34. package/dist/{types/core → core}/build/vite-plugin-hoisted-scripts.d.ts +0 -0
  35. package/dist/{types/core → core}/build/vite-plugin-internals.d.ts +0 -0
  36. package/dist/{types/core → core}/build/vite-plugin-pages.d.ts +0 -0
  37. package/dist/{types/core → core}/build/vite-plugin-ssr.d.ts +0 -0
  38. package/dist/{types/core → core}/config.d.ts +11 -1
  39. package/dist/core/config.js +5 -2
  40. package/dist/{types/core → core}/create-vite.d.ts +0 -0
  41. package/dist/{types/core → core}/dev/index.d.ts +0 -0
  42. package/dist/core/dev/index.js +1 -1
  43. package/dist/{types/core → core}/endpoint/dev/index.d.ts +0 -0
  44. package/dist/{types/core → core}/endpoint/index.d.ts +0 -0
  45. package/dist/{types/core → core}/errors.d.ts +0 -0
  46. package/dist/{types/core → core}/logger/console.d.ts +0 -0
  47. package/dist/{types/core → core}/logger/core.d.ts +0 -0
  48. package/dist/{types/core → core}/logger/node.d.ts +0 -0
  49. package/dist/{types/core → core}/messages.d.ts +0 -0
  50. package/dist/core/messages.js +2 -2
  51. package/dist/{types/core → core}/path.d.ts +0 -0
  52. package/dist/{types/core → core}/polyfill.d.ts +0 -0
  53. package/dist/{types/core → core}/preview/index.d.ts +0 -0
  54. package/dist/{types/core → core}/preview/util.d.ts +0 -0
  55. package/dist/{types/core → core}/render/core.d.ts +0 -0
  56. package/dist/{types/core → core}/render/dev/css.d.ts +0 -0
  57. package/dist/{types/core → core}/render/dev/index.d.ts +0 -0
  58. package/dist/{types/core → core}/render/dev/resolve.d.ts +0 -0
  59. package/dist/{types/core → core}/render/dev/scripts.d.ts +0 -0
  60. package/dist/{types/core → core}/render/dev/vite.d.ts +0 -0
  61. package/dist/{types/core → core}/render/paginate.d.ts +0 -0
  62. package/dist/{types/core → core}/render/result.d.ts +0 -0
  63. package/dist/core/render/result.js +18 -7
  64. package/dist/{types/core → core}/render/route-cache.d.ts +0 -0
  65. package/dist/{types/core → core}/render/script.d.ts +0 -0
  66. package/dist/{types/core → core}/render/ssr-element.d.ts +0 -0
  67. package/dist/{types/core → core}/render/util.d.ts +0 -0
  68. package/dist/{types/core → core}/request.d.ts +0 -0
  69. package/dist/{types/core → core}/routing/index.d.ts +0 -0
  70. package/dist/{types/core → core}/routing/manifest/create.d.ts +0 -0
  71. package/dist/{types/core → core}/routing/manifest/generator.d.ts +0 -0
  72. package/dist/{types/core → core}/routing/manifest/serialization.d.ts +0 -0
  73. package/dist/{types/core → core}/routing/match.d.ts +0 -0
  74. package/dist/{types/core → core}/routing/params.d.ts +0 -0
  75. package/dist/{types/core → core}/routing/validation.d.ts +0 -0
  76. package/dist/{types/core → core}/util.d.ts +0 -0
  77. package/dist/core/util.js +5 -5
  78. package/dist/{types/events → events}/error.d.ts +0 -0
  79. package/dist/{types/events → events}/index.d.ts +0 -0
  80. package/dist/{types/events → events}/session.d.ts +0 -0
  81. package/dist/{types/integrations → integrations}/index.d.ts +0 -0
  82. package/dist/{types/jsx → jsx}/babel.d.ts +0 -0
  83. package/dist/{types/jsx → jsx}/renderer.d.ts +0 -0
  84. package/dist/{types/jsx → jsx}/server.d.ts +0 -0
  85. package/dist/{types/jsx-runtime → jsx-runtime}/index.d.ts +0 -0
  86. package/dist/{types/runtime → runtime}/client/events.d.ts +0 -0
  87. package/dist/{types/runtime → runtime}/client/hmr.d.ts +0 -0
  88. package/dist/{types/runtime → runtime}/client/idle.d.ts +0 -0
  89. package/dist/{types/runtime → runtime}/client/idle.prebuilt.d.ts +0 -0
  90. package/dist/{types/runtime → runtime}/client/load.d.ts +0 -0
  91. package/dist/{types/runtime → runtime}/client/load.prebuilt.d.ts +0 -0
  92. package/dist/{types/runtime → runtime}/client/media.d.ts +0 -0
  93. package/dist/{types/runtime → runtime}/client/media.prebuilt.d.ts +0 -0
  94. package/dist/{types/runtime → runtime}/client/only.d.ts +0 -0
  95. package/dist/{types/runtime → runtime}/client/only.prebuilt.d.ts +0 -0
  96. package/dist/{types/runtime → runtime}/client/visible.d.ts +0 -0
  97. package/dist/{types/runtime → runtime}/client/visible.prebuilt.d.ts +0 -0
  98. package/dist/{types/runtime → runtime}/server/astro-global.d.ts +0 -0
  99. package/dist/runtime/server/astro-global.js +1 -1
  100. package/dist/{types/runtime → runtime}/server/astro-island.d.ts +0 -0
  101. package/dist/runtime/server/astro-island.js +5 -4
  102. package/dist/runtime/server/astro-island.prebuilt.d.ts +7 -0
  103. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  104. package/dist/{types/runtime → runtime}/server/endpoint.d.ts +0 -0
  105. package/dist/{types/runtime → runtime}/server/escape.d.ts +0 -0
  106. package/dist/{types/runtime → runtime}/server/hydration.d.ts +0 -0
  107. package/dist/{types/runtime → runtime}/server/index.d.ts +0 -0
  108. package/dist/{types/runtime → runtime}/server/jsx.d.ts +0 -0
  109. package/dist/{types/runtime → runtime}/server/metadata.d.ts +0 -0
  110. package/dist/{types/runtime → runtime}/server/render/any.d.ts +0 -0
  111. package/dist/{types/runtime → runtime}/server/render/astro.d.ts +0 -0
  112. package/dist/{types/runtime → runtime}/server/render/common.d.ts +0 -0
  113. package/dist/{types/runtime → runtime}/server/render/component.d.ts +0 -0
  114. package/dist/{types/runtime → runtime}/server/render/dom.d.ts +0 -0
  115. package/dist/{types/runtime → runtime}/server/render/head.d.ts +0 -0
  116. package/dist/{types/runtime → runtime}/server/render/index.d.ts +0 -0
  117. package/dist/{types/runtime → runtime}/server/render/page.d.ts +0 -0
  118. package/dist/{types/runtime → runtime}/server/render/types.d.ts +0 -0
  119. package/dist/{types/runtime → runtime}/server/render/util.d.ts +0 -0
  120. package/dist/{types/runtime → runtime}/server/response.d.ts +0 -0
  121. package/dist/{types/runtime → runtime}/server/scripts.d.ts +0 -0
  122. package/dist/{types/runtime → runtime}/server/serialize.d.ts +0 -0
  123. package/dist/{types/runtime → runtime}/server/shorthash.d.ts +0 -0
  124. package/dist/{types/runtime → runtime}/server/util.d.ts +0 -0
  125. package/dist/{types/template → template}/4xx.d.ts +0 -0
  126. package/dist/{types/template → template}/css.d.ts +0 -0
  127. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/compile.d.ts +5 -3
  128. package/dist/vite-plugin-astro/compile.js +18 -30
  129. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/hmr.d.ts +1 -10
  130. package/dist/vite-plugin-astro/hmr.js +4 -24
  131. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/index.d.ts +0 -0
  132. package/dist/vite-plugin-astro/index.js +14 -14
  133. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/query.d.ts +0 -0
  134. package/dist/vite-plugin-astro/styles.d.ts +18 -0
  135. package/dist/vite-plugin-astro/styles.js +23 -18
  136. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/types.d.ts +0 -0
  137. package/dist/{types/vite-plugin-astro-postprocess → vite-plugin-astro-postprocess}/index.d.ts +0 -0
  138. package/dist/{types/vite-plugin-astro-server → vite-plugin-astro-server}/index.d.ts +0 -0
  139. package/dist/{types/vite-plugin-config-alias → vite-plugin-config-alias}/index.d.ts +0 -0
  140. package/dist/{types/vite-plugin-env → vite-plugin-env}/index.d.ts +0 -0
  141. package/dist/{types/vite-plugin-html → vite-plugin-html}/index.d.ts +0 -0
  142. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/escape.d.ts +0 -0
  143. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/index.d.ts +0 -0
  144. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/slots.d.ts +0 -0
  145. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/utils.d.ts +0 -0
  146. package/dist/{types/vite-plugin-integrations-container → vite-plugin-integrations-container}/index.d.ts +0 -0
  147. package/dist/{types/vite-plugin-jsx → vite-plugin-jsx}/index.d.ts +0 -0
  148. package/dist/{types/vite-plugin-jsx → vite-plugin-jsx}/tag.d.ts +0 -0
  149. package/dist/vite-plugin-jsx/tag.js +16 -28
  150. package/dist/{types/vite-plugin-markdown → vite-plugin-markdown}/index.d.ts +0 -0
  151. package/dist/vite-plugin-markdown/index.js +2 -0
  152. package/dist/{types/vite-plugin-markdown-legacy → vite-plugin-markdown-legacy}/index.d.ts +0 -0
  153. package/dist/vite-plugin-markdown-legacy/index.js +8 -4
  154. package/dist/{types/vite-plugin-scripts → vite-plugin-scripts}/index.d.ts +0 -0
  155. package/dist/{types/vite-plugin-scripts → vite-plugin-scripts}/page-ssr.d.ts +0 -0
  156. package/dist/{types/vite-plugin-utils → vite-plugin-utils}/index.d.ts +0 -0
  157. package/env.d.ts +3 -3
  158. package/package.json +15 -9
  159. package/tsconfigs/base.json +20 -0
  160. package/tsconfigs/strict.json +9 -0
  161. package/tsconfigs/strictest.json +24 -0
  162. package/dist/types/runtime/server/astro-island.prebuilt.d.ts +0 -7
  163. package/dist/types/vite-plugin-astro/styles.d.ts +0 -16
package/astro-jsx.d.ts CHANGED
@@ -23,12 +23,12 @@ declare namespace astroHTML.JSX {
23
23
  children?: Children;
24
24
  }
25
25
 
26
- type AstroBuiltinProps = import('./dist/types/@types/astro').AstroBuiltinProps;
27
- type AstroBuiltinAttributes = import('./dist/types/@types/astro').AstroBuiltinAttributes;
28
- type AstroDefineVarsAttribute = import('./dist/types/@types/astro').AstroDefineVarsAttribute;
29
- type AstroScriptAttributes = import('./dist/types/@types/astro').AstroScriptAttributes &
26
+ type AstroBuiltinProps = import('./dist/@types/astro').AstroBuiltinProps;
27
+ type AstroBuiltinAttributes = import('./dist/@types/astro').AstroBuiltinAttributes;
28
+ type AstroDefineVarsAttribute = import('./dist/@types/astro').AstroDefineVarsAttribute;
29
+ type AstroScriptAttributes = import('./dist/@types/astro').AstroScriptAttributes &
30
30
  AstroDefineVarsAttribute;
31
- type AstroStyleAttributes = import('./dist/types/@types/astro').AstroStyleAttributes &
31
+ type AstroStyleAttributes = import('./dist/@types/astro').AstroStyleAttributes &
32
32
  AstroDefineVarsAttribute;
33
33
 
34
34
  // This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework
package/client-base.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /// <reference types="vite/types/importMeta" />
1
+ /// <reference path="./import-meta.d.ts" />
2
2
 
3
3
  // CSS modules
4
4
  type CSSModuleClasses = { readonly [key: string]: string };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig } from '@astrojs/markdown-remark';
2
+ import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
3
3
  import type * as babel from '@babel/core';
4
4
  import type { AddressInfo } from 'net';
5
5
  import type * as vite from 'vite';
@@ -179,7 +179,7 @@ export interface AstroGlobal extends AstroGlobalPartial {
179
179
  */
180
180
  has(slotName: string): boolean;
181
181
  /**
182
- * Asychronously renders this slot and returns HTML
182
+ * Asynchronously renders this slot and returns a string
183
183
  *
184
184
  * Example usage:
185
185
  * ```astro
@@ -192,6 +192,21 @@ export interface AstroGlobal extends AstroGlobalPartial {
192
192
  * <Fragment set:html={html} />
193
193
  * ```
194
194
  *
195
+ * A second parameters can be used to pass arguments to a slotted callback
196
+ *
197
+ * Example usage:
198
+ * ```astro
199
+ * ---
200
+ * html = await Astro.slots.render('default', ["Hello", "World"])
201
+ * ---
202
+ * ```
203
+ * Each item in the array will be passed as an argument that you can use like so:
204
+ * ```astro
205
+ * <Component>
206
+ * {(hello, world) => <div>{hello}, {world}!</div>}
207
+ * </Component>
208
+ * ```
209
+ *
195
210
  * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
196
211
  */
197
212
  render(slotName: string, args?: any[]): Promise<string>;
@@ -377,7 +392,7 @@ export interface AstroUserConfig {
377
392
  * @name trailingSlash
378
393
  * @type {('always' | 'never' | 'ignore')}
379
394
  * @default `'ignore'`
380
- * @see buildOptions.pageUrlFormat
395
+ * @see build.format
381
396
  * @description
382
397
  *
383
398
  * Set the route matching behavior of the dev server. Choose from the following options:
@@ -463,6 +478,13 @@ export interface AstroUserConfig {
463
478
  * }
464
479
  * }
465
480
  * ```
481
+ *
482
+ * #### Effect on Astro.url
483
+ * Setting `build.format` controls what `Astro.url` is set to during the build. When it is:
484
+ * - `directory` - The `Astro.url.pathname` will include a trailing slash to mimic folder behavior; ie `/foo/`.
485
+ * - `file` - The `Astro.url.pathname` will include `.html`; ie `/foo.html`.
486
+ *
487
+ * This means that when you create relative URLs using `new URL('./relative', Astro.url)`, you will get consistent behavior between dev and build.
466
488
  */
467
489
  format?: 'file' | 'directory';
468
490
  };
@@ -580,17 +602,19 @@ export interface AstroUserConfig {
580
602
  * @name markdown.remarkPlugins
581
603
  * @type {RemarkPlugins}
582
604
  * @description
583
- * Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built.
605
+ * 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.
584
606
  *
585
- * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support and [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
607
+ * :::caution
608
+ * Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
609
+ * :::
586
610
  *
587
611
  * ```js
612
+ * import remarkToc from 'remark-toc';
588
613
  * {
589
614
  * markdown: {
590
- * // Example: The default set of remark plugins used by Astro
591
- * remarkPlugins: ['remark-gfm', 'remark-smartypants'],
592
- * },
593
- * };
615
+ * remarkPlugins: [remarkToc]
616
+ * }
617
+ * }
594
618
  * ```
595
619
  */
596
620
  remarkPlugins?: RemarkPlugins;
@@ -599,20 +623,58 @@ export interface AstroUserConfig {
599
623
  * @name markdown.rehypePlugins
600
624
  * @type {RehypePlugins}
601
625
  * @description
602
- * Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built.
626
+ * 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.
627
+ *
628
+ * :::caution
629
+ * Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
630
+ * :::
631
+ *
632
+ * ```js
633
+ * import rehypeMinifyHtml from 'rehype-minify';
634
+ * {
635
+ * markdown: {
636
+ * rehypePlugins: [rehypeMinifyHtml]
637
+ * }
638
+ * }
639
+ * ```
640
+ */
641
+ rehypePlugins?: RehypePlugins;
642
+ /**
643
+ * @docs
644
+ * @name markdown.extendDefaultPlugins
645
+ * @type {boolean}
646
+ * @default `false`
647
+ * @description
648
+ * Astro applies the [GitHub-flavored Markdown](https://github.com/remarkjs/remark-gfm) and [Smartypants](https://github.com/silvenon/remark-smartypants) plugins by default. When adding your own remark or rehype plugins, you can preserve these defaults by setting the `extendDefaultPlugins` flag to `true`:
603
649
  *
604
- * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support and [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
650
+ * ```js
651
+ * {
652
+ * markdown: {
653
+ * extendDefaultPlugins: true,
654
+ * remarkPlugins: [exampleRemarkPlugin],
655
+ * rehypePlugins: [exampleRehypePlugin],
656
+ * }
657
+ * }
658
+ * ```
659
+ */
660
+ extendDefaultPlugins?: boolean;
661
+ /**
662
+ * @docs
663
+ * @name markdown.remarkRehype
664
+ * @type {RemarkRehype}
665
+ * @description
666
+ * Pass options to [remark-rehype](https://github.com/remarkjs/remark-rehype#api).
605
667
  *
606
668
  * ```js
607
669
  * {
608
670
  * markdown: {
609
- * // Example: The default set of rehype plugins used by Astro
610
- * rehypePlugins: [],
671
+ * // Example: Translate the footnotes text to another language, here are the default English values
672
+ * remarkRehype: { footnoteLabel: "Footnotes", footnoteBackLabel: "Back to content"},
611
673
  * },
612
674
  * };
613
675
  * ```
614
676
  */
615
- rehypePlugins?: RehypePlugins;
677
+ remarkRehype?: RemarkRehype;
616
678
  };
617
679
  /**
618
680
  * @docs
@@ -765,36 +827,35 @@ export interface AstroInstance {
765
827
  }
766
828
  export interface MarkdownInstance<T extends Record<string, any>> {
767
829
  frontmatter: T;
830
+ /** Absolute file path (e.g. `/home/user/projects/.../file.md`) */
768
831
  file: string;
832
+ /** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */
769
833
  url: string | undefined;
834
+ /** Component to render content in `.astro` files. Usage: `<Content />` */
770
835
  Content: AstroComponentFactory;
771
- /** raw Markdown file content, excluding frontmatter */
836
+ /** raw Markdown file content, excluding layout HTML and YAML frontmatter */
772
837
  rawContent(): string;
773
- /** Markdown file compiled to valid Astro syntax. Queryable with most HTML parsing libraries */
774
- compiledContent(): Promise<string>;
775
- getHeadings(): Promise<MarkdownHeading[]>;
838
+ /** Markdown file compiled to HTML, excluding layout HTML */
839
+ compiledContent(): string;
840
+ /** List of headings (h1 -> h6) with associated metadata */
841
+ getHeadings(): MarkdownHeading[];
776
842
  /** @deprecated Renamed to `getHeadings()` */
777
843
  getHeaders(): void;
778
- default: () => Promise<{
779
- metadata: MarkdownMetadata;
780
- frontmatter: MarkdownContent<T>;
781
- $$metadata: Metadata;
782
- default: AstroComponentFactory;
783
- }>;
844
+ default: AstroComponentFactory;
784
845
  }
785
- export interface MDXInstance<T> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent' | 'Content' | 'default'> {
846
+ export interface MDXInstance<T> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> {
786
847
  /** MDX does not support rawContent! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
787
848
  rawContent: never;
788
849
  /** MDX does not support compiledContent! If you need to read the HTML contents to calculate values (ex. reading time), we suggest injecting frontmatter via rehype plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
789
850
  compiledContent: never;
790
- default: AstroComponentFactory;
791
- Content: AstroComponentFactory;
792
851
  }
793
852
  export interface MarkdownLayoutProps<T extends Record<string, any>> {
794
853
  frontmatter: {
795
854
  file: MarkdownInstance<T>['file'];
796
855
  url: MarkdownInstance<T>['url'];
797
856
  } & T;
857
+ file: MarkdownInstance<T>['file'];
858
+ url: MarkdownInstance<T>['url'];
798
859
  headings: MarkdownHeading[];
799
860
  rawContent: MarkdownInstance<T>['rawContent'];
800
861
  compiledContent: MarkdownInstance<T>['compiledContent'];
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -156,6 +156,21 @@ async function getPathsForRoute(pageData, mod, opts, builtPaths) {
156
156
  function addPageName(pathname, opts) {
157
157
  opts.pageNames.push(pathname.replace(/^\//, ""));
158
158
  }
159
+ function getUrlForPath(pathname, base, origin, format, routeType) {
160
+ const ending = format === "directory" ? "/" : ".html";
161
+ let buildPathname;
162
+ if (pathname === "/" || pathname === "") {
163
+ buildPathname = base;
164
+ } else if (routeType === "endpoint") {
165
+ const buildPathRelative = removeLeadingForwardSlash(pathname);
166
+ buildPathname = base + buildPathRelative;
167
+ } else {
168
+ const buildPathRelative = removeTrailingForwardSlash(removeLeadingForwardSlash(pathname)) + ending;
169
+ buildPathname = base + buildPathRelative;
170
+ }
171
+ const url = new URL(buildPathname, origin);
172
+ return url;
173
+ }
159
174
  async function generatePath(pathname, opts, gopts) {
160
175
  var _a;
161
176
  const { astroConfig, logging, origin, routeCache } = opts;
@@ -187,7 +202,13 @@ async function generatePath(pathname, opts, gopts) {
187
202
  }
188
203
  }
189
204
  const ssr = opts.astroConfig.output === "server";
190
- const url = new URL(opts.astroConfig.base + removeLeadingForwardSlash(pathname), origin);
205
+ const url = getUrlForPath(
206
+ pathname,
207
+ opts.astroConfig.base,
208
+ origin,
209
+ opts.astroConfig.build.format,
210
+ pageData.route.type
211
+ );
191
212
  const options = {
192
213
  adapterName: void 0,
193
214
  links,
@@ -2,6 +2,7 @@ import type { GetModuleInfo, ModuleInfo } from 'rollup';
2
2
  export declare function walkParentInfos(id: string, ctx: {
3
3
  getModuleInfo: GetModuleInfo;
4
4
  }, depth?: number, seen?: Set<string>): Generator<[ModuleInfo, number], void, unknown>;
5
+ export declare function moduleIsTopLevelPage(info: ModuleInfo): boolean;
5
6
  export declare function getTopLevelPages(id: string, ctx: {
6
7
  getModuleInfo: GetModuleInfo;
7
8
  }): Generator<[ModuleInfo, number], void, unknown>;
@@ -13,15 +13,18 @@ function* walkParentInfos(id, ctx, depth = 0, seen = /* @__PURE__ */ new Set())
13
13
  yield* walkParentInfos(imp, ctx, ++depth, seen);
14
14
  }
15
15
  }
16
+ function moduleIsTopLevelPage(info) {
17
+ return info.importers[0] === resolvedPagesVirtualModuleId;
18
+ }
16
19
  function* getTopLevelPages(id, ctx) {
17
- var _a;
18
20
  for (const res of walkParentInfos(id, ctx)) {
19
- if (((_a = res[0]) == null ? void 0 : _a.importers[0]) === resolvedPagesVirtualModuleId) {
21
+ if (moduleIsTopLevelPage(res[0])) {
20
22
  yield res;
21
23
  }
22
24
  }
23
25
  }
24
26
  export {
25
27
  getTopLevelPages,
28
+ moduleIsTopLevelPage,
26
29
  walkParentInfos
27
30
  };
File without changes
@@ -58,3 +58,5 @@ export declare function eachPageData(internals: BuildInternals): Generator<PageB
58
58
  * and page-level CSS on bottom.
59
59
  */
60
60
  export declare function sortedCSS(pageData: PageBuildData): string[];
61
+ export declare function isHoistedScript(internals: BuildInternals, id: string): boolean;
62
+ export declare function getPageDatasByHoistedScriptId(internals: BuildInternals, id: string): Generator<PageBuildData, void, unknown>;
@@ -2,9 +2,6 @@ import { prependForwardSlash } from "../path.js";
2
2
  import { viteID } from "../util.js";
3
3
  function createBuildInternals() {
4
4
  const pureCSSChunks = /* @__PURE__ */ new Set();
5
- const chunkToReferenceIdMap = /* @__PURE__ */ new Map();
6
- const astroStyleMap = /* @__PURE__ */ new Map();
7
- const astroPageStyleMap = /* @__PURE__ */ new Map();
8
5
  const hoistedScriptIdToHoistedMap = /* @__PURE__ */ new Map();
9
6
  const hoistedScriptIdToPagesMap = /* @__PURE__ */ new Map();
10
7
  return {
@@ -88,6 +85,20 @@ function sortedCSS(pageData) {
88
85
  }
89
86
  }).map(([id]) => id);
90
87
  }
88
+ function isHoistedScript(internals, id) {
89
+ return internals.hoistedScriptIdToPagesMap.has(id);
90
+ }
91
+ function* getPageDatasByHoistedScriptId(internals, id) {
92
+ const set = internals.hoistedScriptIdToPagesMap.get(id);
93
+ if (set) {
94
+ for (const pageId of set) {
95
+ const pageData = getPageDataByComponent(internals, pageId.slice(1));
96
+ if (pageData) {
97
+ yield pageData;
98
+ }
99
+ }
100
+ }
101
+ }
91
102
  export {
92
103
  createBuildInternals,
93
104
  eachPageData,
@@ -95,7 +106,9 @@ export {
95
106
  getPageDataByViteID,
96
107
  getPageDatasByChunk,
97
108
  getPageDatasByClientOnlyID,
109
+ getPageDatasByHoistedScriptId,
98
110
  hasPageDataByViteID,
111
+ isHoistedScript,
99
112
  sortedCSS,
100
113
  trackClientOnlyPageDatas,
101
114
  trackPageData
File without changes
@@ -122,7 +122,8 @@ async function ssrBuild(opts, internals, input) {
122
122
  vitePluginAnalyzer(internals)
123
123
  ],
124
124
  publicDir: ssr ? false : viteConfig.publicDir,
125
- envPrefix: "PUBLIC_"
125
+ envPrefix: "PUBLIC_",
126
+ base: astroConfig.base
126
127
  };
127
128
  await runHookBuildSetup({
128
129
  config: astroConfig,
@@ -181,7 +182,8 @@ ${bgGreen(black(" building client "))}`);
181
182
  }),
182
183
  ...viteConfig.plugins || []
183
184
  ],
184
- envPrefix: "PUBLIC_"
185
+ envPrefix: "PUBLIC_",
186
+ base: astroConfig.base
185
187
  };
186
188
  await runHookBuildSetup({
187
189
  config: astroConfig,
File without changes
File without changes
@@ -3,12 +3,19 @@ import esbuild from "esbuild";
3
3
  import npath from "path";
4
4
  import { isCSSRequest } from "../render/util.js";
5
5
  import { relativeToSrcDir } from "../util.js";
6
- import { getTopLevelPages, walkParentInfos } from "./graph.js";
7
- import { getPageDataByViteID, getPageDatasByClientOnlyID } from "./internal.js";
6
+ import { getTopLevelPages, moduleIsTopLevelPage, walkParentInfos } from "./graph.js";
7
+ import {
8
+ eachPageData,
9
+ getPageDataByViteID,
10
+ getPageDatasByClientOnlyID,
11
+ getPageDatasByHoistedScriptId,
12
+ isHoistedScript
13
+ } from "./internal.js";
8
14
  const MAX_NAME_LENGTH = 70;
9
15
  function rollupPluginAstroBuildCSS(options) {
10
16
  const { internals, buildOptions } = options;
11
17
  const { astroConfig } = buildOptions;
18
+ let resolvedConfig;
12
19
  function nameifyPage(id) {
13
20
  let rel = relativeToSrcDir(astroConfig, id);
14
21
  if (rel.startsWith("pages/")) {
@@ -58,13 +65,24 @@ function rollupPluginAstroBuildCSS(options) {
58
65
  };
59
66
  },
60
67
  async generateBundle(_outputOptions, bundle) {
68
+ const appendCSSToPage = (pageData, meta, depth) => {
69
+ for (const importedCssImport of meta.importedCss) {
70
+ if (pageData == null ? void 0 : pageData.css.has(importedCssImport)) {
71
+ const cssInfo = pageData == null ? void 0 : pageData.css.get(importedCssImport);
72
+ if (depth < cssInfo.depth) {
73
+ cssInfo.depth = depth;
74
+ }
75
+ } else {
76
+ pageData == null ? void 0 : pageData.css.set(importedCssImport, { depth });
77
+ }
78
+ }
79
+ };
61
80
  for (const [_, chunk] of Object.entries(bundle)) {
62
81
  if (chunk.type === "chunk") {
63
82
  const c = chunk;
64
83
  if ("viteMetadata" in chunk) {
65
84
  const meta = chunk["viteMetadata"];
66
85
  if (meta.importedCss.size) {
67
- debugger;
68
86
  if (options.target === "client") {
69
87
  for (const [id] of Object.entries(c.modules)) {
70
88
  for (const pageData of getParentClientOnlys(id, this)) {
@@ -75,18 +93,19 @@ function rollupPluginAstroBuildCSS(options) {
75
93
  }
76
94
  }
77
95
  for (const [id] of Object.entries(c.modules)) {
78
- debugger;
79
- for (const [pageInfo, depth] of getTopLevelPages(id, this)) {
80
- const pageViteID = pageInfo.id;
81
- const pageData = getPageDataByViteID(internals, pageViteID);
82
- for (const importedCssImport of meta.importedCss) {
83
- if (pageData == null ? void 0 : pageData.css.has(importedCssImport)) {
84
- const cssInfo = pageData == null ? void 0 : pageData.css.get(importedCssImport);
85
- if (depth < cssInfo.depth) {
86
- cssInfo.depth = depth;
87
- }
88
- } else {
89
- pageData == null ? void 0 : pageData.css.set(importedCssImport, { depth });
96
+ for (const [pageInfo, depth] of walkParentInfos(id, this)) {
97
+ if (moduleIsTopLevelPage(pageInfo)) {
98
+ const pageViteID = pageInfo.id;
99
+ const pageData = getPageDataByViteID(internals, pageViteID);
100
+ if (pageData) {
101
+ appendCSSToPage(pageData, meta, depth);
102
+ }
103
+ } else if (options.target === "client" && isHoistedScript(internals, pageInfo.id)) {
104
+ for (const pageData of getPageDatasByHoistedScriptId(
105
+ internals,
106
+ pageInfo.id
107
+ )) {
108
+ appendCSSToPage(pageData, meta, -1);
90
109
  }
91
110
  }
92
111
  }
@@ -97,6 +116,25 @@ function rollupPluginAstroBuildCSS(options) {
97
116
  }
98
117
  }
99
118
  },
119
+ {
120
+ name: "astro:rollup-plugin-single-css",
121
+ enforce: "post",
122
+ configResolved(config) {
123
+ resolvedConfig = config;
124
+ },
125
+ generateBundle(_, bundle) {
126
+ if (!resolvedConfig.build.cssCodeSplit) {
127
+ const cssChunk = Object.values(bundle).find(
128
+ (chunk) => chunk.type === "asset" && chunk.name === "style.css"
129
+ );
130
+ if (cssChunk) {
131
+ for (const pageData of eachPageData(internals)) {
132
+ pageData.css.set(cssChunk.fileName, { depth: -1 });
133
+ }
134
+ }
135
+ }
136
+ }
137
+ },
100
138
  {
101
139
  name: "astro:rollup-plugin-build-css-minify",
102
140
  enforce: "post",
@@ -1,4 +1,4 @@
1
- import type { RehypePlugin, RemarkPlugin } from '@astrojs/markdown-remark';
1
+ import type { RehypePlugin, RemarkPlugin, RemarkRehype } from '@astrojs/markdown-remark';
2
2
  import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
3
3
  import type { Arguments as Flags } from 'yargs-parser';
4
4
  import type { AstroConfig, AstroUserConfig, CLIFlags, ViteUserConfig } from '../@types/astro';
@@ -103,6 +103,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
103
103
  }>>;
104
104
  remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin<any[]>, z.ZodTypeDef, RemarkPlugin<any[]>>, z.ZodTuple<[z.ZodType<RemarkPlugin<any[]>, z.ZodTypeDef, RemarkPlugin<any[]>>, z.ZodAny], null>]>, "many">>;
105
105
  rehypePlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RehypePlugin<any[]>, z.ZodTypeDef, RehypePlugin<any[]>>, z.ZodTuple<[z.ZodType<RehypePlugin<any[]>, z.ZodTypeDef, RehypePlugin<any[]>>, z.ZodAny], null>]>, "many">>;
106
+ remarkRehype: z.ZodDefault<z.ZodOptional<z.ZodType<RemarkRehype, z.ZodTypeDef, RemarkRehype>>>;
107
+ extendDefaultPlugins: z.ZodDefault<z.ZodBoolean>;
106
108
  }, "strip", z.ZodTypeAny, {
107
109
  drafts: boolean;
108
110
  syntaxHighlight: false | "shiki" | "prism";
@@ -113,6 +115,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
113
115
  };
114
116
  remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
115
117
  rehypePlugins: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[];
118
+ remarkRehype: RemarkRehype;
119
+ extendDefaultPlugins: boolean;
116
120
  }, {
117
121
  drafts?: boolean | undefined;
118
122
  syntaxHighlight?: false | "shiki" | "prism" | undefined;
@@ -123,6 +127,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
123
127
  } | undefined;
124
128
  remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
125
129
  rehypePlugins?: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[] | undefined;
130
+ remarkRehype?: RemarkRehype | undefined;
131
+ extendDefaultPlugins?: boolean | undefined;
126
132
  }>>;
127
133
  vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
128
134
  legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{
@@ -149,6 +155,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
149
155
  };
150
156
  remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
151
157
  rehypePlugins: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[];
158
+ remarkRehype: RemarkRehype;
159
+ extendDefaultPlugins: boolean;
152
160
  };
153
161
  root: URL;
154
162
  srcDir: URL;
@@ -190,6 +198,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
190
198
  } | undefined;
191
199
  remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
192
200
  rehypePlugins?: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[] | undefined;
201
+ remarkRehype?: RemarkRehype | undefined;
202
+ extendDefaultPlugins?: boolean | undefined;
193
203
  } | undefined;
194
204
  root?: string | undefined;
195
205
  srcDir?: string | undefined;
@@ -36,7 +36,8 @@ const ASTRO_CONFIG_DEFAULTS = {
36
36
  wrap: false
37
37
  },
38
38
  remarkPlugins: [],
39
- rehypePlugins: []
39
+ rehypePlugins: [],
40
+ remarkRehype: {}
40
41
  },
41
42
  vite: {},
42
43
  legacy: {
@@ -125,7 +126,9 @@ const AstroConfigSchema = z.object({
125
126
  z.tuple([z.string(), z.any()]),
126
127
  z.custom((data) => typeof data === "function"),
127
128
  z.tuple([z.custom((data) => typeof data === "function"), z.any()])
128
- ]).array().default(ASTRO_CONFIG_DEFAULTS.markdown.rehypePlugins)
129
+ ]).array().default(ASTRO_CONFIG_DEFAULTS.markdown.rehypePlugins),
130
+ remarkRehype: z.custom((data) => data instanceof Object && !Array.isArray(data)).optional().default(ASTRO_CONFIG_DEFAULTS.markdown.remarkRehype),
131
+ extendDefaultPlugins: z.boolean().default(false)
129
132
  }).default({}),
130
133
  vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
131
134
  legacy: z.object({
File without changes
File without changes
@@ -46,7 +46,7 @@ async function dev(config, options) {
46
46
  https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
47
47
  })
48
48
  );
49
- const currentVersion = "1.0.8";
49
+ const currentVersion = "1.1.0";
50
50
  if (currentVersion.includes("-")) {
51
51
  warn(options.logging, null, msg.prerelease({ currentVersion }));
52
52
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes