astro 1.0.9 → 1.1.1

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 (149) 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 +72 -26
  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 +0 -0
  22. package/dist/{types/core → core}/build/index.d.ts +0 -0
  23. package/dist/{types/core → core}/build/internal.d.ts +0 -0
  24. package/dist/{types/core → core}/build/page-data.d.ts +0 -0
  25. package/dist/{types/core → core}/build/static-build.d.ts +0 -0
  26. package/dist/{types/core → core}/build/types.d.ts +0 -0
  27. package/dist/{types/core → core}/build/util.d.ts +0 -0
  28. package/dist/{types/core → core}/build/vite-plugin-analyzer.d.ts +0 -0
  29. package/dist/{types/core → core}/build/vite-plugin-css.d.ts +0 -0
  30. package/dist/{types/core → core}/build/vite-plugin-hoisted-scripts.d.ts +0 -0
  31. package/dist/{types/core → core}/build/vite-plugin-internals.d.ts +0 -0
  32. package/dist/{types/core → core}/build/vite-plugin-pages.d.ts +0 -0
  33. package/dist/{types/core → core}/build/vite-plugin-ssr.d.ts +0 -0
  34. package/dist/{types/core → core}/config.d.ts +11 -1
  35. package/dist/core/config.js +5 -2
  36. package/dist/{types/core → core}/create-vite.d.ts +0 -0
  37. package/dist/{types/core → core}/dev/index.d.ts +0 -0
  38. package/dist/core/dev/index.js +1 -1
  39. package/dist/{types/core → core}/endpoint/dev/index.d.ts +0 -0
  40. package/dist/{types/core → core}/endpoint/index.d.ts +0 -0
  41. package/dist/{types/core → core}/errors.d.ts +0 -0
  42. package/dist/{types/core → core}/logger/console.d.ts +0 -0
  43. package/dist/{types/core → core}/logger/core.d.ts +0 -0
  44. package/dist/{types/core → core}/logger/node.d.ts +0 -0
  45. package/dist/{types/core → core}/messages.d.ts +0 -0
  46. package/dist/core/messages.js +2 -2
  47. package/dist/{types/core → core}/path.d.ts +0 -0
  48. package/dist/{types/core → core}/polyfill.d.ts +0 -0
  49. package/dist/{types/core → core}/preview/index.d.ts +0 -0
  50. package/dist/{types/core → core}/preview/util.d.ts +0 -0
  51. package/dist/{types/core → core}/render/core.d.ts +0 -0
  52. package/dist/{types/core → core}/render/dev/css.d.ts +0 -0
  53. package/dist/{types/core → core}/render/dev/index.d.ts +0 -0
  54. package/dist/{types/core → core}/render/dev/resolve.d.ts +0 -0
  55. package/dist/{types/core → core}/render/dev/scripts.d.ts +0 -0
  56. package/dist/{types/core → core}/render/dev/vite.d.ts +0 -0
  57. package/dist/{types/core → core}/render/paginate.d.ts +0 -0
  58. package/dist/{types/core → core}/render/result.d.ts +0 -0
  59. package/dist/{types/core → core}/render/route-cache.d.ts +0 -0
  60. package/dist/{types/core → core}/render/script.d.ts +0 -0
  61. package/dist/{types/core → core}/render/ssr-element.d.ts +0 -0
  62. package/dist/{types/core → core}/render/util.d.ts +0 -0
  63. package/dist/{types/core → core}/request.d.ts +0 -0
  64. package/dist/{types/core → core}/routing/index.d.ts +0 -0
  65. package/dist/{types/core → core}/routing/manifest/create.d.ts +0 -0
  66. package/dist/{types/core → core}/routing/manifest/generator.d.ts +0 -0
  67. package/dist/{types/core → core}/routing/manifest/serialization.d.ts +0 -0
  68. package/dist/{types/core → core}/routing/match.d.ts +0 -0
  69. package/dist/{types/core → core}/routing/params.d.ts +0 -0
  70. package/dist/{types/core → core}/routing/validation.d.ts +0 -0
  71. package/dist/{types/core → core}/util.d.ts +0 -0
  72. package/dist/core/util.js +5 -5
  73. package/dist/{types/events → events}/error.d.ts +0 -0
  74. package/dist/{types/events → events}/index.d.ts +0 -0
  75. package/dist/{types/events → events}/session.d.ts +0 -0
  76. package/dist/{types/integrations → integrations}/index.d.ts +0 -0
  77. package/dist/{types/jsx → jsx}/babel.d.ts +0 -0
  78. package/dist/{types/jsx → jsx}/renderer.d.ts +0 -0
  79. package/dist/{types/jsx → jsx}/server.d.ts +0 -0
  80. package/dist/{types/jsx-runtime → jsx-runtime}/index.d.ts +0 -0
  81. package/dist/{types/runtime → runtime}/client/events.d.ts +0 -0
  82. package/dist/{types/runtime → runtime}/client/hmr.d.ts +0 -0
  83. package/dist/{types/runtime → runtime}/client/idle.d.ts +0 -0
  84. package/dist/{types/runtime → runtime}/client/idle.prebuilt.d.ts +0 -0
  85. package/dist/{types/runtime → runtime}/client/load.d.ts +0 -0
  86. package/dist/{types/runtime → runtime}/client/load.prebuilt.d.ts +0 -0
  87. package/dist/{types/runtime → runtime}/client/media.d.ts +0 -0
  88. package/dist/{types/runtime → runtime}/client/media.prebuilt.d.ts +0 -0
  89. package/dist/{types/runtime → runtime}/client/only.d.ts +0 -0
  90. package/dist/{types/runtime → runtime}/client/only.prebuilt.d.ts +0 -0
  91. package/dist/{types/runtime → runtime}/client/visible.d.ts +0 -0
  92. package/dist/{types/runtime → runtime}/client/visible.prebuilt.d.ts +0 -0
  93. package/dist/{types/runtime → runtime}/server/astro-global.d.ts +0 -0
  94. package/dist/runtime/server/astro-global.js +1 -1
  95. package/dist/{types/runtime → runtime}/server/astro-island.d.ts +0 -0
  96. package/dist/{types/runtime → runtime}/server/astro-island.prebuilt.d.ts +0 -0
  97. package/dist/{types/runtime → runtime}/server/endpoint.d.ts +0 -0
  98. package/dist/{types/runtime → runtime}/server/escape.d.ts +0 -0
  99. package/dist/{types/runtime → runtime}/server/hydration.d.ts +0 -0
  100. package/dist/{types/runtime → runtime}/server/index.d.ts +0 -0
  101. package/dist/{types/runtime → runtime}/server/jsx.d.ts +0 -0
  102. package/dist/{types/runtime → runtime}/server/metadata.d.ts +0 -0
  103. package/dist/{types/runtime → runtime}/server/render/any.d.ts +0 -0
  104. package/dist/{types/runtime → runtime}/server/render/astro.d.ts +0 -0
  105. package/dist/{types/runtime → runtime}/server/render/common.d.ts +0 -0
  106. package/dist/{types/runtime → runtime}/server/render/component.d.ts +0 -0
  107. package/dist/{types/runtime → runtime}/server/render/dom.d.ts +0 -0
  108. package/dist/{types/runtime → runtime}/server/render/head.d.ts +0 -0
  109. package/dist/{types/runtime → runtime}/server/render/index.d.ts +0 -0
  110. package/dist/{types/runtime → runtime}/server/render/page.d.ts +0 -0
  111. package/dist/{types/runtime → runtime}/server/render/types.d.ts +0 -0
  112. package/dist/{types/runtime → runtime}/server/render/util.d.ts +0 -0
  113. package/dist/{types/runtime → runtime}/server/response.d.ts +0 -0
  114. package/dist/{types/runtime → runtime}/server/scripts.d.ts +0 -0
  115. package/dist/{types/runtime → runtime}/server/serialize.d.ts +0 -0
  116. package/dist/{types/runtime → runtime}/server/shorthash.d.ts +0 -0
  117. package/dist/{types/runtime → runtime}/server/util.d.ts +0 -0
  118. package/dist/{types/template → template}/4xx.d.ts +0 -0
  119. package/dist/{types/template → template}/css.d.ts +0 -0
  120. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/compile.d.ts +0 -0
  121. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/hmr.d.ts +0 -0
  122. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/index.d.ts +0 -0
  123. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/query.d.ts +0 -0
  124. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/styles.d.ts +0 -0
  125. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/types.d.ts +0 -0
  126. package/dist/{types/vite-plugin-astro-postprocess → vite-plugin-astro-postprocess}/index.d.ts +0 -0
  127. package/dist/{types/vite-plugin-astro-server → vite-plugin-astro-server}/index.d.ts +0 -0
  128. package/dist/{types/vite-plugin-config-alias → vite-plugin-config-alias}/index.d.ts +0 -0
  129. package/dist/{types/vite-plugin-env → vite-plugin-env}/index.d.ts +0 -0
  130. package/dist/{types/vite-plugin-html → vite-plugin-html}/index.d.ts +0 -0
  131. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/escape.d.ts +0 -0
  132. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/index.d.ts +0 -0
  133. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/slots.d.ts +0 -0
  134. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/utils.d.ts +0 -0
  135. package/dist/{types/vite-plugin-integrations-container → vite-plugin-integrations-container}/index.d.ts +0 -0
  136. package/dist/{types/vite-plugin-jsx → vite-plugin-jsx}/index.d.ts +0 -0
  137. package/dist/{types/vite-plugin-jsx → vite-plugin-jsx}/tag.d.ts +0 -0
  138. package/dist/{types/vite-plugin-markdown → vite-plugin-markdown}/index.d.ts +0 -0
  139. package/dist/vite-plugin-markdown/index.js +2 -0
  140. package/dist/{types/vite-plugin-markdown-legacy → vite-plugin-markdown-legacy}/index.d.ts +0 -0
  141. package/dist/{types/vite-plugin-scripts → vite-plugin-scripts}/index.d.ts +0 -0
  142. package/dist/{types/vite-plugin-scripts → vite-plugin-scripts}/page-ssr.d.ts +0 -0
  143. package/dist/{types/vite-plugin-utils → vite-plugin-utils}/index.d.ts +0 -0
  144. package/env.d.ts +3 -3
  145. package/import-meta.d.ts +37 -0
  146. package/package.json +15 -7
  147. package/tsconfigs/base.json +20 -0
  148. package/tsconfigs/strict.json +9 -0
  149. package/tsconfigs/strictest.json +24 -0
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';
@@ -392,7 +392,7 @@ export interface AstroUserConfig {
392
392
  * @name trailingSlash
393
393
  * @type {('always' | 'never' | 'ignore')}
394
394
  * @default `'ignore'`
395
- * @see buildOptions.pageUrlFormat
395
+ * @see build.format
396
396
  * @description
397
397
  *
398
398
  * Set the route matching behavior of the dev server. Choose from the following options:
@@ -478,6 +478,13 @@ export interface AstroUserConfig {
478
478
  * }
479
479
  * }
480
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.
481
488
  */
482
489
  format?: 'file' | 'directory';
483
490
  };
@@ -595,17 +602,19 @@ export interface AstroUserConfig {
595
602
  * @name markdown.remarkPlugins
596
603
  * @type {RemarkPlugins}
597
604
  * @description
598
- * 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.
599
606
  *
600
- * **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
+ * :::
601
610
  *
602
611
  * ```js
612
+ * import remarkToc from 'remark-toc';
603
613
  * {
604
614
  * markdown: {
605
- * // Example: The default set of remark plugins used by Astro
606
- * remarkPlugins: ['remark-gfm', 'remark-smartypants'],
607
- * },
608
- * };
615
+ * remarkPlugins: [remarkToc]
616
+ * }
617
+ * }
609
618
  * ```
610
619
  */
611
620
  remarkPlugins?: RemarkPlugins;
@@ -614,20 +623,58 @@ export interface AstroUserConfig {
614
623
  * @name markdown.rehypePlugins
615
624
  * @type {RehypePlugins}
616
625
  * @description
617
- * 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.
618
627
  *
619
- * **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.
628
+ * :::caution
629
+ * Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
630
+ * :::
620
631
  *
621
632
  * ```js
633
+ * import rehypeMinifyHtml from 'rehype-minify';
622
634
  * {
623
635
  * markdown: {
624
- * // Example: The default set of rehype plugins used by Astro
625
- * rehypePlugins: [],
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`:
649
+ *
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).
667
+ *
668
+ * ```js
669
+ * {
670
+ * markdown: {
671
+ * // Example: Translate the footnotes text to another language, here are the default English values
672
+ * remarkRehype: { footnoteLabel: "Footnotes", footnoteBackLabel: "Back to content"},
626
673
  * },
627
674
  * };
628
675
  * ```
629
676
  */
630
- rehypePlugins?: RehypePlugins;
677
+ remarkRehype?: RemarkRehype;
631
678
  };
632
679
  /**
633
680
  * @docs
@@ -780,36 +827,35 @@ export interface AstroInstance {
780
827
  }
781
828
  export interface MarkdownInstance<T extends Record<string, any>> {
782
829
  frontmatter: T;
830
+ /** Absolute file path (e.g. `/home/user/projects/.../file.md`) */
783
831
  file: string;
832
+ /** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */
784
833
  url: string | undefined;
834
+ /** Component to render content in `.astro` files. Usage: `<Content />` */
785
835
  Content: AstroComponentFactory;
786
- /** raw Markdown file content, excluding frontmatter */
836
+ /** raw Markdown file content, excluding layout HTML and YAML frontmatter */
787
837
  rawContent(): string;
788
- /** Markdown file compiled to valid Astro syntax. Queryable with most HTML parsing libraries */
789
- compiledContent(): Promise<string>;
790
- 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[];
791
842
  /** @deprecated Renamed to `getHeadings()` */
792
843
  getHeaders(): void;
793
- default: () => Promise<{
794
- metadata: MarkdownMetadata;
795
- frontmatter: MarkdownContent<T>;
796
- $$metadata: Metadata;
797
- default: AstroComponentFactory;
798
- }>;
844
+ default: AstroComponentFactory;
799
845
  }
800
- export interface MDXInstance<T> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent' | 'Content' | 'default'> {
846
+ export interface MDXInstance<T> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> {
801
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 */
802
848
  rawContent: never;
803
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 */
804
850
  compiledContent: never;
805
- default: AstroComponentFactory;
806
- Content: AstroComponentFactory;
807
851
  }
808
852
  export interface MarkdownLayoutProps<T extends Record<string, any>> {
809
853
  frontmatter: {
810
854
  file: MarkdownInstance<T>['file'];
811
855
  url: MarkdownInstance<T>['url'];
812
856
  } & T;
857
+ file: MarkdownInstance<T>['file'];
858
+ url: MarkdownInstance<T>['url'];
813
859
  headings: MarkdownHeading[];
814
860
  rawContent: MarkdownInstance<T>['rawContent'];
815
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,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -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.9";
49
+ const currentVersion = "1.1.1";
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
@@ -46,7 +46,7 @@ function devStart({
46
46
  https,
47
47
  site
48
48
  }) {
49
- const version = "1.0.9";
49
+ const version = "1.1.1";
50
50
  const rootPath = site ? site.pathname : "/";
51
51
  const localPrefix = `${dim("\u2503")} Local `;
52
52
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -225,7 +225,7 @@ function printHelp({
225
225
  message.push(
226
226
  linebreak(),
227
227
  ` ${bgGreen(black(` ${commandName} `))} ${green(
228
- `v${"1.0.9"}`
228
+ `v${"1.1.1"}`
229
229
  )} ${headline}`
230
230
  );
231
231
  }
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
File without changes
File without changes
package/dist/core/util.js CHANGED
@@ -5,7 +5,7 @@ import resolve from "resolve";
5
5
  import slash from "slash";
6
6
  import { fileURLToPath, pathToFileURL } from "url";
7
7
  import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
8
- const ASTRO_VERSION = "1.0.9";
8
+ const ASTRO_VERSION = "1.1.1";
9
9
  function isObject(value) {
10
10
  return typeof value === "object" && value != null;
11
11
  }
@@ -17,7 +17,7 @@ function padMultilineString(source, n = 2) {
17
17
  return lines.map((l) => ` `.repeat(n) + l).join(`
18
18
  `);
19
19
  }
20
- const STATUS_CODE_REGEXP = /^\/?[0-9]{3}$/;
20
+ const REGEXP_404_OR_500_ROUTE = /(404)|(500)\/?$/;
21
21
  function getOutputFilename(astroConfig, name, type) {
22
22
  if (type === "endpoint") {
23
23
  return name;
@@ -25,10 +25,10 @@ function getOutputFilename(astroConfig, name, type) {
25
25
  if (name === "/" || name === "") {
26
26
  return path.posix.join(name, "index.html");
27
27
  }
28
- if (astroConfig.build.format === "directory" && !STATUS_CODE_REGEXP.test(name)) {
29
- return path.posix.join(name, "index.html");
28
+ if (astroConfig.build.format === "file" || REGEXP_404_OR_500_ROUTE.test(name)) {
29
+ return `${removeTrailingForwardSlash(name || "index")}.html`;
30
30
  }
31
- return `${removeTrailingForwardSlash(name || "index")}.html`;
31
+ return path.posix.join(name, "index.html");
32
32
  }
33
33
  function parseNpmName(spec) {
34
34
  if (!spec || spec[0] === "." || spec[0] === "/")
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
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "1.0.9";
1
+ const ASTRO_VERSION = "1.1.1";
2
2
  function createDeprecatedFetchContentFn() {
3
3
  return () => {
4
4
  throw new Error("Deprecated: Astro.fetchContent() has been replaced with Astro.glob().");
File without changes
File without changes
File without changes
File without changes
@@ -85,6 +85,8 @@ function markdown({ config, logging }) {
85
85
  });
86
86
  const contentFragment = h(Fragment, { 'set:html': html });
87
87
  return ${layout ? `h(Layout, {
88
+ file,
89
+ url,
88
90
  content,
89
91
  frontmatter: content,
90
92
  headings: getHeadings(),
package/env.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./client.d.ts" />
2
2
 
3
- type Astro = import('./dist/types/@types/astro').AstroGlobal;
3
+ type Astro = import('./dist/@types/astro').AstroGlobal;
4
4
 
5
5
  // We duplicate the description here because editors won't show the JSDoc comment from the imported type (but will for its properties, ex: Astro.request will show the AstroGlobal.request description)
6
6
  /**
@@ -13,7 +13,7 @@ declare const Astro: Readonly<Astro>;
13
13
  declare const Fragment: any;
14
14
 
15
15
  declare module '*.md' {
16
- type MD = import('./dist/types/@types/astro').MarkdownInstance<Record<string, any>>;
16
+ type MD = import('./dist/@types/astro').MarkdownInstance<Record<string, any>>;
17
17
 
18
18
  export const frontmatter: MD['frontmatter'];
19
19
  export const file: MD['file'];
@@ -30,7 +30,7 @@ declare module '*.md' {
30
30
  }
31
31
 
32
32
  declare module '*.mdx' {
33
- type MDX = import('astro').MDXInstance<Record<string, any>>;
33
+ type MDX = import('./dist/@types/astro').MDXInstance<Record<string, any>>;
34
34
 
35
35
  export const frontmatter: MDX['frontmatter'];
36
36
  export const file: MDX['file'];
@@ -0,0 +1,37 @@
1
+ // File vendored from Vite itself, as a workaround to https://github.com/vitejs/vite/pull/9827 until Vite 4 comes out
2
+
3
+ // This file is an augmentation to the built-in ImportMeta interface
4
+ // Thus cannot contain any top-level imports
5
+ // <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>
6
+
7
+ /* eslint-disable @typescript-eslint/consistent-type-imports */
8
+
9
+ // Duplicate of import('../src/node/importGlob').GlobOptions in order to
10
+ // avoid breaking the production client type. Because this file is referenced
11
+ // in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist.
12
+ interface GlobOptions {
13
+ as?: string;
14
+ }
15
+
16
+ interface ImportMeta {
17
+ url: string;
18
+
19
+ readonly hot?: import('vite/types/hot').ViteHotContext;
20
+
21
+ readonly env: ImportMetaEnv;
22
+
23
+ glob: import('vite/types/importGlob').ImportGlobFunction;
24
+ /**
25
+ * @deprecated Use `import.meta.glob('*', { eager: true })` instead
26
+ */
27
+ globEager: import('vite/types/importGlob').ImportGlobEagerFunction;
28
+ }
29
+
30
+ interface ImportMetaEnv {
31
+ [key: string]: any;
32
+ BASE_URL: string;
33
+ MODE: string;
34
+ DEV: boolean;
35
+ PROD: boolean;
36
+ SSR: boolean;
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -12,23 +12,29 @@
12
12
  },
13
13
  "bugs": "https://github.com/withastro/astro/issues",
14
14
  "homepage": "https://astro.build",
15
- "types": "./dist/types/@types/astro.d.ts",
15
+ "types": "./dist/@types/astro.d.ts",
16
16
  "typesVersions": {
17
17
  "*": {
18
18
  "app": [
19
- "./dist/types/core/app/index"
19
+ "./dist/core/app/index"
20
20
  ],
21
21
  "app/*": [
22
- "./dist/types/core/app/*"
22
+ "./dist/core/app/*"
23
23
  ]
24
24
  }
25
25
  },
26
26
  "exports": {
27
- ".": "./astro.js",
27
+ ".": {
28
+ "types": "./dist/@types/astro.d.ts",
29
+ "default": "./astro.js"
30
+ },
28
31
  "./env": "./env.d.ts",
29
32
  "./client": "./client.d.ts",
30
33
  "./client-base": "./client-base.d.ts",
34
+ "./import-meta": "./import-meta.d.ts",
31
35
  "./astro-jsx": "./astro-jsx.d.ts",
36
+ "./tsconfigs/*.json": "./tsconfigs/*",
37
+ "./tsconfigs/*": "./tsconfigs/*.json",
32
38
  "./jsx/*": "./dist/jsx/*",
33
39
  "./jsx-runtime": "./dist/jsx-runtime/index.js",
34
40
  "./config": "./config.mjs",
@@ -62,6 +68,7 @@
62
68
  },
63
69
  "files": [
64
70
  "components",
71
+ "tsconfigs",
65
72
  "dist",
66
73
  "astro.js",
67
74
  "config.d.ts",
@@ -69,14 +76,15 @@
69
76
  "env.d.ts",
70
77
  "client.d.ts",
71
78
  "client-base.d.ts",
79
+ "import-meta.d.ts",
72
80
  "astro-jsx.d.ts",
73
81
  "README.md",
74
82
  "vendor"
75
83
  ],
76
84
  "dependencies": {
77
85
  "@astrojs/compiler": "^0.23.4",
78
- "@astrojs/language-server": "^0.20.0",
79
- "@astrojs/markdown-remark": "^1.0.0",
86
+ "@astrojs/language-server": "^0.23.0",
87
+ "@astrojs/markdown-remark": "^1.1.0",
80
88
  "@astrojs/telemetry": "^1.0.0",
81
89
  "@astrojs/webapi": "^1.0.0",
82
90
  "@babel/core": "^7.18.2",
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ // Enable top-level await, and other modern ESM features.
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ // Enable node-style module resolution, for things like npm package imports.
8
+ "moduleResolution": "node",
9
+ // Enable JSON imports.
10
+ "resolveJsonModule": true,
11
+ // Enable stricter transpilation for better output.
12
+ "isolatedModules": true,
13
+ // Astro directly run TypeScript code, no transpilation needed.
14
+ "noEmit": true,
15
+ // Report an error when importing a file using a casing different from the casing on disk.
16
+ "forceConsistentCasingInFileNames": true,
17
+ // Properly support importing CJS modules in ESM
18
+ "esModuleInterop": true
19
+ }
20
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "strict": true,
6
+ // Error when a value import is only used as a type.
7
+ "importsNotUsedAsValues": "error"
8
+ }
9
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./strict.json",
4
+ "compilerOptions": {
5
+ // Report errors for fallthrough cases in switch statements
6
+ "noFallthroughCasesInSwitch": true,
7
+ // Force functions designed to override their parent class to be specified as `override`.
8
+ "noImplicitOverride": true,
9
+ // Force functions to specify that they can return `undefined` if a possible code path does not return a value.
10
+ "noImplicitReturns": true,
11
+ // Report an error when a variable is declared but never used.
12
+ "noUnusedLocals": true,
13
+ // Report an error when a parameter is declared but never used.
14
+ "noUnusedParameters": true,
15
+ // Force the usage of the indexed syntax to access fields declared using an index signature.
16
+ "noUncheckedIndexedAccess": true,
17
+ // Report an error when the value `undefined` is given to an optional property that doesn't specify `undefined` as a valid value.
18
+ "exactOptionalPropertyTypes": true,
19
+ // Report an error for unreachable code instead of just a warning.
20
+ "allowUnreachableCode": false,
21
+ // Report an error for unused labels instead of just a warning.
22
+ "allowUnusedLabels": false
23
+ }
24
+ }