astro 1.0.0-beta.5 → 1.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -30,7 +30,6 @@ function printAstroHelp() {
30
30
  ["--config <path>", "Specify the path to the Astro config file."],
31
31
  ["--root <path>", "Specify the path to the project root folder."],
32
32
  ["--legacy-build", "Use the build strategy prior to 0.24.0"],
33
- ["--experimental-ssr", "Enable SSR compilation fot 3rd-party adapters."],
34
33
  ["--drafts", "Include markdown draft pages in the build."],
35
34
  ["--verbose", "Enable verbose logging"],
36
35
  ["--silent", "Disable logging"]
@@ -38,7 +37,7 @@ function printAstroHelp() {
38
37
  });
39
38
  }
40
39
  async function printVersion() {
41
- const version = "1.0.0-beta.5";
40
+ const version = "1.0.0-beta.8";
42
41
  console.log();
43
42
  console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
44
43
  }
@@ -95,7 +95,7 @@ renderPage_fn = async function(request, routeData, mod) {
95
95
  legacyBuild: false,
96
96
  links,
97
97
  logging: __privateGet(this, _logging),
98
- markdownRender: manifest.markdown.render,
98
+ markdown: manifest.markdown,
99
99
  mod,
100
100
  origin: url.origin,
101
101
  pathname: url.pathname,
@@ -1,4 +1,3 @@
1
- import astroRemark from "@astrojs/markdown-remark";
2
1
  import fs from "fs";
3
2
  import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
4
3
  import npath from "path";
@@ -122,7 +121,7 @@ async function generatePath(pathname, opts, gopts) {
122
121
  legacyBuild: false,
123
122
  links,
124
123
  logging,
125
- markdownRender: [astroRemark, astroConfig.markdown],
124
+ markdown: astroConfig.markdown,
126
125
  mod,
127
126
  origin,
128
127
  pathname,
@@ -204,11 +204,11 @@ async function copyFiles(fromFolder, toFolder) {
204
204
  const files = await glob("**/*", {
205
205
  cwd: fileURLToPath(fromFolder)
206
206
  });
207
- await fs.promises.mkdir(toFolder, { recursive: true });
208
207
  await Promise.all(files.map(async (filename) => {
209
208
  const from = new URL(filename, fromFolder);
210
209
  const to = new URL(filename, toFolder);
211
- return fs.promises.copyFile(from, to);
210
+ const lastFolder = new URL("./", to);
211
+ return fs.promises.mkdir(lastFolder, { recursive: true }).then(() => fs.promises.copyFile(from, to));
212
212
  }));
213
213
  }
214
214
  async function ssrMoveAssets(opts) {
@@ -1,4 +1,3 @@
1
- import astroRemark from "@astrojs/markdown-remark";
2
1
  import { serializeRouteData } from "../routing/index.js";
3
2
  import { eachPageData } from "./internal.js";
4
3
  import { addRollupInput } from "./add-rollup-input.js";
@@ -83,9 +82,7 @@ function buildManifest(opts, internals) {
83
82
  const ssrManifest = {
84
83
  routes,
85
84
  site: astroConfig.site,
86
- markdown: {
87
- render: [astroRemark, astroConfig.markdown]
88
- },
85
+ markdown: astroConfig.markdown,
89
86
  pageMap: null,
90
87
  renderers: [],
91
88
  entryModules
@@ -21,6 +21,7 @@ import * as colors from "kleur/colors";
21
21
  import path from "path";
22
22
  import { pathToFileURL, fileURLToPath } from "url";
23
23
  import { mergeConfig as mergeViteConfig } from "vite";
24
+ import { BUNDLED_THEMES } from "shiki";
24
25
  import { z } from "zod";
25
26
  import load, { ProloadError } from "@proload/core";
26
27
  import loadTypeScript from "@proload/plugin-tsm";
@@ -88,13 +89,27 @@ const AstroConfigSchema = z.object({
88
89
  }).optional().default({ options: {}, plugins: [] })
89
90
  }).optional().default({}),
90
91
  markdown: z.object({
91
- drafts: z.boolean().optional().default(false),
92
- mode: z.union([z.literal("md"), z.literal("mdx")]).optional().default("mdx"),
93
- syntaxHighlight: z.union([z.literal("shiki"), z.literal("prism"), z.literal(false)]).optional().default("shiki"),
94
- shikiConfig: z.any().optional().default({}),
95
- remarkPlugins: z.array(z.any()).optional().default([]),
96
- rehypePlugins: z.array(z.any()).optional().default([])
97
- }).passthrough().optional().default({}),
92
+ mode: z.enum(["md", "mdx"]).default("mdx"),
93
+ drafts: z.boolean().default(false),
94
+ syntaxHighlight: z.union([z.literal("shiki"), z.literal("prism"), z.literal(false)]).default("shiki"),
95
+ shikiConfig: z.object({
96
+ langs: z.custom().array().default([]),
97
+ theme: z.enum(BUNDLED_THEMES).or(z.custom()).default("github-dark"),
98
+ wrap: z.boolean().or(z.null()).default(false)
99
+ }).default({}),
100
+ remarkPlugins: z.union([
101
+ z.string(),
102
+ z.tuple([z.string(), z.any()]),
103
+ z.custom((data) => typeof data === "function"),
104
+ z.tuple([z.custom((data) => typeof data === "function"), z.any()])
105
+ ]).array().default([]),
106
+ rehypePlugins: z.union([
107
+ z.string(),
108
+ z.tuple([z.string(), z.any()]),
109
+ z.custom((data) => typeof data === "function"),
110
+ z.tuple([z.custom((data) => typeof data === "function"), z.any()])
111
+ ]).array().default([])
112
+ }).default({}),
98
113
  vite: z.any().optional().default({}),
99
114
  experimental: z.object({
100
115
  ssr: z.boolean().optional().default(false),
@@ -36,7 +36,7 @@ async function dev(config, options = { logging: nodeLogOptions }) {
36
36
  site,
37
37
  https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
38
38
  }));
39
- const currentVersion = "1.0.0-beta.5";
39
+ const currentVersion = "1.0.0-beta.8";
40
40
  if (currentVersion.includes("-")) {
41
41
  warn(options.logging, null, msg.prerelease({ currentVersion }));
42
42
  }
@@ -45,7 +45,7 @@ function devStart({
45
45
  https,
46
46
  site
47
47
  }) {
48
- const version = "1.0.0-beta.5";
48
+ const version = "1.0.0-beta.8";
49
49
  const rootPath = site ? site.pathname : "/";
50
50
  const localPrefix = `${dim("\u2503")} Local `;
51
51
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -170,7 +170,7 @@ function printHelp({
170
170
  };
171
171
  let message = [];
172
172
  if (headline) {
173
- message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.5"}`)} ${headline}`);
173
+ message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.8"}`)} ${headline}`);
174
174
  }
175
175
  if (usage) {
176
176
  message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
@@ -54,7 +54,7 @@ async function render(opts) {
54
54
  links,
55
55
  logging,
56
56
  origin,
57
- markdownRender,
57
+ markdown,
58
58
  mod,
59
59
  pathname,
60
60
  scripts,
@@ -87,7 +87,7 @@ async function render(opts) {
87
87
  legacyBuild,
88
88
  links,
89
89
  logging,
90
- markdownRender,
90
+ markdown,
91
91
  origin,
92
92
  params,
93
93
  pathname,
@@ -17,7 +17,6 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import astroRemark from "@astrojs/markdown-remark";
21
20
  import { fileURLToPath } from "url";
22
21
  import { render as coreRender } from "../core.js";
23
22
  import { prependForwardSlash } from "../../../core/path.js";
@@ -105,7 +104,7 @@ async function render(renderers, mod, ssrOpts) {
105
104
  legacyBuild: isLegacyBuild,
106
105
  links,
107
106
  logging,
108
- markdownRender: [astroRemark, astroConfig.markdown],
107
+ markdown: astroConfig.markdown,
109
108
  mod,
110
109
  origin,
111
110
  pathname,
@@ -105,8 +105,9 @@ Please update the name of this slot.`);
105
105
  _cache = new WeakMap();
106
106
  _result = new WeakMap();
107
107
  _slots = new WeakMap();
108
+ let renderMarkdown = null;
108
109
  function createResult(args) {
109
- const { legacyBuild, markdownRender, params, pathname, renderers, request, resolve, site } = args;
110
+ const { legacyBuild, markdown, params, pathname, renderers, request, resolve, site } = args;
110
111
  const url = new URL(request.url);
111
112
  const canonicalURL = createCanonicalURL("." + pathname, site ?? url.origin);
112
113
  const result = {
@@ -162,24 +163,14 @@ ${extra}`);
162
163
  enumerable: false,
163
164
  writable: false,
164
165
  value: async function(content, opts) {
165
- let [mdRender, renderOpts] = markdownRender;
166
- let parser = null;
167
- if (Array.isArray(mdRender)) {
168
- renderOpts = mdRender[1];
169
- mdRender = mdRender[0];
166
+ if (typeof Deno !== "undefined") {
167
+ throw new Error("Markdown is not supported in Deno SSR");
170
168
  }
171
- if (typeof mdRender === "string") {
172
- const mod = await import(mdRender);
173
- parser = mod.default;
174
- } else if (mdRender instanceof Promise) {
175
- const mod = await mdRender;
176
- parser = mod.default;
177
- } else if (typeof mdRender === "function") {
178
- parser = mdRender;
179
- } else {
180
- throw new Error("No Markdown parser found.");
169
+ if (!renderMarkdown) {
170
+ let astroRemark = "@astrojs/markdown-remark";
171
+ renderMarkdown = (await import(astroRemark)).renderMarkdown;
181
172
  }
182
- const { code } = await parser(content, __spreadValues(__spreadValues({}, renderOpts), opts ?? {}));
173
+ const { code } = await renderMarkdown(content, __spreadValues(__spreadValues({}, markdown), opts ?? {}));
183
174
  return code;
184
175
  }
185
176
  });
@@ -3,7 +3,7 @@ import type { AddressInfo } from 'net';
3
3
  import type * as babel from '@babel/core';
4
4
  import type * as vite from 'vite';
5
5
  import { z } from 'zod';
6
- import type { ShikiConfig, Plugin } from '@astrojs/markdown-remark';
6
+ import type { ShikiConfig, RemarkPlugins, RehypePlugins } from '@astrojs/markdown-remark';
7
7
  import type { AstroConfigSchema } from '../core/config';
8
8
  import type { AstroComponentFactory, Metadata } from '../runtime/server';
9
9
  import type { ViteConfigWithSSR } from '../core/create-vite';
@@ -62,21 +62,107 @@ export interface BuildConfig {
62
62
  staticMode: boolean | undefined;
63
63
  }
64
64
  /**
65
- * Astro.* available in all components
66
- * Docs: https://docs.astro.build/reference/api-reference/#astro-global
65
+ * Astro global available in all contexts in .astro files
66
+ *
67
+ * [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global)
67
68
  */
68
69
  export interface AstroGlobal extends AstroGlobalPartial {
69
- /** get the current canonical URL */
70
+ /** Canonical URL of the current page. If the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option is set, its origin will be the origin of this URL.
71
+ *
72
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrocanonicalurl)
73
+ */
70
74
  canonicalURL: URL;
71
- /** get page params (dynamic pages only) */
75
+ /** Parameters passed to a dynamic page generated using [getStaticPaths](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
76
+ *
77
+ * Example usage:
78
+ * ```astro
79
+ * ---
80
+ * export async function getStaticPaths() {
81
+ * return [
82
+ * { params: { id: '1' } },
83
+ * ];
84
+ * }
85
+ *
86
+ * const { id } = Astro.params;
87
+ * ---
88
+ * <h1>{id}</h1>
89
+ * ```
90
+ *
91
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#params)
92
+ */
72
93
  params: Params;
73
- /** set props for this astro component (along with default values) */
94
+ /** List of props passed to this component
95
+ *
96
+ * A common way to get specific props is through [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment), ex:
97
+ * ```typescript
98
+ * const { name } = Astro.props
99
+ * ```
100
+ *
101
+ * [Astro reference](https://docs.astro.build/en/core-concepts/astro-components/#component-props)
102
+ */
74
103
  props: Record<string, number | string | any>;
75
- /** get information about this page */
104
+ /** Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object
105
+ *
106
+ * For example, to get a URL object of the current URL, you can use:
107
+ * ```typescript
108
+ * const url = new URL(Astro.request.url);
109
+ * ```
110
+ *
111
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrorequest)
112
+ */
76
113
  request: Request;
77
- /** see if slots are used */
114
+ /** Redirect to another page (**SSR Only**)
115
+ *
116
+ * Example usage:
117
+ * ```typescript
118
+ * if(!isLoggedIn) {
119
+ * return Astro.redirect('/login');
120
+ * }
121
+ * ```
122
+ *
123
+ * [Astro reference](https://docs.astro.build/en/guides/server-side-rendering/#astroredirect)
124
+ */
125
+ redirect(path: string): Response;
126
+ /**
127
+ * The <Astro.self /> element allows a component to reference itself recursively.
128
+ *
129
+ * [Astro reference](https://docs.astro.build/en/guides/server-side-rendering/#astroself)
130
+ */
131
+ self: AstroComponentFactory;
132
+ /** Utility functions for modifying an Astro component’s slotted children
133
+ *
134
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
135
+ */
78
136
  slots: Record<string, true | undefined> & {
137
+ /**
138
+ * Check whether content for this slot name exists
139
+ *
140
+ * Example usage:
141
+ * ```typescript
142
+ * if (Astro.slots.has('default')) {
143
+ * // Do something...
144
+ * }
145
+ * ```
146
+ *
147
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
148
+ */
79
149
  has(slotName: string): boolean;
150
+ /**
151
+ * Asychronously renders this slot and returns HTML
152
+ *
153
+ * Example usage:
154
+ * ```astro
155
+ * ---
156
+ * let html: string = '';
157
+ * if (Astro.slots.has('default')) {
158
+ * html = await Astro.slots.render('default')
159
+ * }
160
+ * ---
161
+ * <Fragment set:html={html} />
162
+ * ```
163
+ *
164
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
165
+ */
80
166
  render(slotName: string, args?: any[]): Promise<string>;
81
167
  };
82
168
  }
@@ -84,12 +170,29 @@ export interface AstroGlobalPartial {
84
170
  /**
85
171
  * @deprecated since version 0.24. See the {@link https://astro.build/deprecated/resolve upgrade guide} for more details.
86
172
  */
87
- resolve: (path: string) => string;
88
- /** @deprecated Use `Astro.glob()` instead. */
173
+ resolve(path: string): string;
174
+ /** @deprecated since version 0.26. Use [Astro.glob()](https://docs.astro.build/en/reference/api-reference/#astroglob) instead. */
89
175
  fetchContent(globStr: string): Promise<any[]>;
176
+ /**
177
+ * Fetch local files into your static site setup
178
+ *
179
+ * Example usage:
180
+ * ```typescript
181
+ * const posts = await Astro.glob('../pages/post/*.md');
182
+ * ```
183
+ *
184
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroglob)
185
+ */
90
186
  glob(globStr: `${any}.astro`): Promise<ComponentInstance[]>;
91
187
  glob<T extends Record<string, any>>(globStr: `${any}.md`): Promise<MarkdownInstance<T>[]>;
92
188
  glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
189
+ /**
190
+ * 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
191
+ *
192
+ * If `site` is undefined, the URL object will instead be built from `localhost`
193
+ *
194
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrosite)
195
+ */
93
196
  site: URL;
94
197
  }
95
198
  declare type ServerConfig = {
@@ -352,14 +455,23 @@ export interface AstroUserConfig {
352
455
  * ```
353
456
  */
354
457
  drafts?: boolean;
458
+ /**
459
+ * @docs
460
+ * @name markdown.mode
461
+ * @type {'md' | 'mdx'}
462
+ * @default `mdx`
463
+ * @description
464
+ * Control wheater to allow components inside markdown files ('mdx') or not ('md').
465
+ */
466
+ mode?: 'md' | 'mdx';
355
467
  /**
356
468
  * @docs
357
469
  * @name markdown.shikiConfig
358
- * @type {ShikiConfig}
470
+ * @typeraw {Partial<ShikiConfig>}
359
471
  * @description
360
472
  * Shiki configuration options. See [the markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage.
361
473
  */
362
- shikiConfig?: ShikiConfig;
474
+ shikiConfig?: Partial<ShikiConfig>;
363
475
  /**
364
476
  * @docs
365
477
  * @name markdown.syntaxHighlight
@@ -384,7 +496,7 @@ export interface AstroUserConfig {
384
496
  /**
385
497
  * @docs
386
498
  * @name markdown.remarkPlugins
387
- * @type {Plugin[]}
499
+ * @type {RemarkPlugins}
388
500
  * @description
389
501
  * Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built.
390
502
  *
@@ -399,11 +511,11 @@ export interface AstroUserConfig {
399
511
  * };
400
512
  * ```
401
513
  */
402
- remarkPlugins?: Plugin[];
514
+ remarkPlugins?: RemarkPlugins;
403
515
  /**
404
516
  * @docs
405
517
  * @name markdown.rehypePlugins
406
- * @type {Plugin[]}
518
+ * @type {RehypePlugins}
407
519
  * @description
408
520
  * Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built.
409
521
  *
@@ -418,7 +530,7 @@ export interface AstroUserConfig {
418
530
  * };
419
531
  * ```
420
532
  */
421
- rehypePlugins?: Plugin[];
533
+ rehypePlugins?: RehypePlugins;
422
534
  };
423
535
  /**
424
536
  * @name adapter
@@ -485,12 +597,12 @@ export interface AstroUserConfig {
485
597
  };
486
598
  experimental?: {
487
599
  /**
488
- * Enable experimental support for 3rd-party integrations.
600
+ * Enable support for 3rd-party integrations.
489
601
  * Default: false
490
602
  */
491
603
  integrations?: boolean;
492
604
  /**
493
- * Enable a build for SSR support.
605
+ * Enable support for 3rd-party SSR adapters.
494
606
  * Default: false
495
607
  */
496
608
  ssr?: boolean;
@@ -594,8 +706,6 @@ export declare type JSXTransformFn = (options: {
594
706
  export interface ManifestData {
595
707
  routes: RouteData[];
596
708
  }
597
- export declare type MarkdownRenderOptions = [string | MarkdownParser, Record<string, any>];
598
- export declare type MarkdownParser = (contents: string, options?: Record<string, any>) => MarkdownParserResponse | PromiseLike<MarkdownParserResponse>;
599
709
  export interface MarkdownParserResponse {
600
710
  frontmatter: {
601
711
  [key: string]: any;
@@ -1,4 +1,5 @@
1
- import type { RouteData, SerializedRouteData, MarkdownRenderOptions, ComponentInstance, SSRLoadedRenderer } from '../../@types/astro';
1
+ import type { RouteData, SerializedRouteData, ComponentInstance, SSRLoadedRenderer } from '../../@types/astro';
2
+ import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
2
3
  export declare type ComponentPath = string;
3
4
  export interface RouteInfo {
4
5
  routeData: RouteData;
@@ -12,9 +13,7 @@ export declare type SerializedRouteInfo = Omit<RouteInfo, 'routeData'> & {
12
13
  export interface SSRManifest {
13
14
  routes: RouteInfo[];
14
15
  site?: string;
15
- markdown: {
16
- render: MarkdownRenderOptions;
17
- };
16
+ markdown: MarkdownRenderingOptions;
18
17
  pageMap: Map<ComponentPath, ComponentInstance>;
19
18
  renderers: SSRLoadedRenderer[];
20
19
  entryModules: Record<string, string>;
@@ -1,5 +1,7 @@
1
1
  import type { AstroConfig, AstroUserConfig, CLIFlags } from '../@types/astro';
2
2
  import type { Arguments as Flags } from 'yargs-parser';
3
+ import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
4
+ import type { RemarkPlugin, RehypePlugin } from '@astrojs/markdown-remark';
3
5
  import { z } from 'zod';
4
6
  export declare const LEGACY_ASTRO_CONFIG_KEYS: Set<string>;
5
7
  export declare const AstroConfigSchema: z.ZodObject<{
@@ -81,28 +83,48 @@ export declare const AstroConfigSchema: z.ZodObject<{
81
83
  plugins: any[];
82
84
  } | undefined;
83
85
  }>>>;
84
- markdown: z.ZodDefault<z.ZodOptional<z.ZodObject<{
85
- drafts: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
86
- mode: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"md">, z.ZodLiteral<"mdx">]>>>;
87
- syntaxHighlight: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"shiki">, z.ZodLiteral<"prism">, z.ZodLiteral<false>]>>>;
88
- shikiConfig: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
89
- remarkPlugins: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodAny, "many">>>;
90
- rehypePlugins: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodAny, "many">>>;
91
- }, "passthrough", z.ZodTypeAny, {
92
- shikiConfig?: any;
93
- drafts: boolean;
86
+ markdown: z.ZodDefault<z.ZodObject<{
87
+ mode: z.ZodDefault<z.ZodEnum<["md", "mdx"]>>;
88
+ drafts: z.ZodDefault<z.ZodBoolean>;
89
+ syntaxHighlight: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"shiki">, z.ZodLiteral<"prism">, z.ZodLiteral<false>]>>;
90
+ shikiConfig: z.ZodDefault<z.ZodObject<{
91
+ langs: z.ZodDefault<z.ZodArray<z.ZodType<ILanguageRegistration, z.ZodTypeDef, ILanguageRegistration>, "many">>;
92
+ theme: z.ZodDefault<z.ZodUnion<[z.ZodEnum<[Theme, ...Theme[]]>, z.ZodType<IThemeRegistration, z.ZodTypeDef, IThemeRegistration>]>>;
93
+ wrap: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodNull]>>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ langs: ILanguageRegistration[];
96
+ theme: "css-variables" | "dark-plus" | "dracula-soft" | "dracula" | "github-dark-dimmed" | "github-dark" | "github-light" | "light-plus" | "material-darker" | "material-default" | "material-lighter" | "material-ocean" | "material-palenight" | "min-dark" | "min-light" | "monokai" | "nord" | "one-dark-pro" | "poimandres" | "rose-pine-dawn" | "rose-pine-moon" | "rose-pine" | "slack-dark" | "slack-ochin" | "solarized-dark" | "solarized-light" | "vitesse-dark" | "vitesse-light" | import("shiki").IShikiTheme | (string & {});
97
+ wrap: boolean | null;
98
+ }, {
99
+ langs?: ILanguageRegistration[] | undefined;
100
+ theme?: "css-variables" | "dark-plus" | "dracula-soft" | "dracula" | "github-dark-dimmed" | "github-dark" | "github-light" | "light-plus" | "material-darker" | "material-default" | "material-lighter" | "material-ocean" | "material-palenight" | "min-dark" | "min-light" | "monokai" | "nord" | "one-dark-pro" | "poimandres" | "rose-pine-dawn" | "rose-pine-moon" | "rose-pine" | "slack-dark" | "slack-ochin" | "solarized-dark" | "solarized-light" | "vitesse-dark" | "vitesse-light" | import("shiki").IShikiTheme | (string & {}) | undefined;
101
+ wrap?: boolean | null | undefined;
102
+ }>>;
103
+ 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">>;
104
+ 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">>;
105
+ }, "strip", z.ZodTypeAny, {
94
106
  mode: "md" | "mdx";
107
+ drafts: boolean;
95
108
  syntaxHighlight: false | "shiki" | "prism";
96
- remarkPlugins: any[];
97
- rehypePlugins: any[];
109
+ shikiConfig: {
110
+ langs: ILanguageRegistration[];
111
+ theme: "css-variables" | "dark-plus" | "dracula-soft" | "dracula" | "github-dark-dimmed" | "github-dark" | "github-light" | "light-plus" | "material-darker" | "material-default" | "material-lighter" | "material-ocean" | "material-palenight" | "min-dark" | "min-light" | "monokai" | "nord" | "one-dark-pro" | "poimandres" | "rose-pine-dawn" | "rose-pine-moon" | "rose-pine" | "slack-dark" | "slack-ochin" | "solarized-dark" | "solarized-light" | "vitesse-dark" | "vitesse-light" | import("shiki").IShikiTheme | (string & {});
112
+ wrap: boolean | null;
113
+ };
114
+ remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
115
+ rehypePlugins: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[];
98
116
  }, {
99
- drafts?: boolean | undefined;
100
117
  mode?: "md" | "mdx" | undefined;
118
+ drafts?: boolean | undefined;
101
119
  syntaxHighlight?: false | "shiki" | "prism" | undefined;
102
- shikiConfig?: any;
103
- remarkPlugins?: any[] | undefined;
104
- rehypePlugins?: any[] | undefined;
105
- }>>>;
120
+ shikiConfig?: {
121
+ langs?: ILanguageRegistration[] | undefined;
122
+ theme?: "css-variables" | "dark-plus" | "dracula-soft" | "dracula" | "github-dark-dimmed" | "github-dark" | "github-light" | "light-plus" | "material-darker" | "material-default" | "material-lighter" | "material-ocean" | "material-palenight" | "min-dark" | "min-light" | "monokai" | "nord" | "one-dark-pro" | "poimandres" | "rose-pine-dawn" | "rose-pine-moon" | "rose-pine" | "slack-dark" | "slack-ochin" | "solarized-dark" | "solarized-light" | "vitesse-dark" | "vitesse-light" | import("shiki").IShikiTheme | (string & {}) | undefined;
123
+ wrap?: boolean | null | undefined;
124
+ } | undefined;
125
+ remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
126
+ rehypePlugins?: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[] | undefined;
127
+ }>>;
106
128
  vite: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
107
129
  experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{
108
130
  ssr: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -145,12 +167,16 @@ export declare const AstroConfigSchema: z.ZodObject<{
145
167
  };
146
168
  };
147
169
  markdown: {
148
- shikiConfig?: any;
149
- drafts: boolean;
150
170
  mode: "md" | "mdx";
171
+ drafts: boolean;
151
172
  syntaxHighlight: false | "shiki" | "prism";
152
- remarkPlugins: any[];
153
- rehypePlugins: any[];
173
+ shikiConfig: {
174
+ langs: ILanguageRegistration[];
175
+ theme: "css-variables" | "dark-plus" | "dracula-soft" | "dracula" | "github-dark-dimmed" | "github-dark" | "github-light" | "light-plus" | "material-darker" | "material-default" | "material-lighter" | "material-ocean" | "material-palenight" | "min-dark" | "min-light" | "monokai" | "nord" | "one-dark-pro" | "poimandres" | "rose-pine-dawn" | "rose-pine-moon" | "rose-pine" | "slack-dark" | "slack-ochin" | "solarized-dark" | "solarized-light" | "vitesse-dark" | "vitesse-light" | import("shiki").IShikiTheme | (string & {});
176
+ wrap: boolean | null;
177
+ };
178
+ remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
179
+ rehypePlugins: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[];
154
180
  };
155
181
  experimental: {
156
182
  integrations: boolean;
@@ -186,12 +212,16 @@ export declare const AstroConfigSchema: z.ZodObject<{
186
212
  } | undefined;
187
213
  } | undefined;
188
214
  markdown?: {
189
- drafts?: boolean | undefined;
190
215
  mode?: "md" | "mdx" | undefined;
216
+ drafts?: boolean | undefined;
191
217
  syntaxHighlight?: false | "shiki" | "prism" | undefined;
192
- shikiConfig?: any;
193
- remarkPlugins?: any[] | undefined;
194
- rehypePlugins?: any[] | undefined;
218
+ shikiConfig?: {
219
+ langs?: ILanguageRegistration[] | undefined;
220
+ theme?: "css-variables" | "dark-plus" | "dracula-soft" | "dracula" | "github-dark-dimmed" | "github-dark" | "github-light" | "light-plus" | "material-darker" | "material-default" | "material-lighter" | "material-ocean" | "material-palenight" | "min-dark" | "min-light" | "monokai" | "nord" | "one-dark-pro" | "poimandres" | "rose-pine-dawn" | "rose-pine-moon" | "rose-pine" | "slack-dark" | "slack-ochin" | "solarized-dark" | "solarized-light" | "vitesse-dark" | "vitesse-light" | import("shiki").IShikiTheme | (string & {}) | undefined;
221
+ wrap?: boolean | null | undefined;
222
+ } | undefined;
223
+ remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
224
+ rehypePlugins?: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[] | undefined;
195
225
  } | undefined;
196
226
  vite?: any;
197
227
  experimental?: {
@@ -1,4 +1,5 @@
1
- import type { ComponentInstance, MarkdownRenderOptions, Params, Props, SSRLoadedRenderer, RouteData, SSRElement } from '../../@types/astro';
1
+ import type { ComponentInstance, Params, Props, SSRLoadedRenderer, RouteData, SSRElement } from '../../@types/astro';
2
+ import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
2
3
  import type { LogOptions } from '../logger/core.js';
3
4
  import { RouteCache } from './route-cache.js';
4
5
  interface GetParamsAndPropsOptions {
@@ -17,7 +18,7 @@ export interface RenderOptions {
17
18
  legacyBuild: boolean;
18
19
  logging: LogOptions;
19
20
  links: Set<SSRElement>;
20
- markdownRender: MarkdownRenderOptions;
21
+ markdown: MarkdownRenderingOptions;
21
22
  mod: ComponentInstance;
22
23
  origin: string;
23
24
  pathname: string;
@@ -1,11 +1,12 @@
1
- import type { MarkdownRenderOptions, Params, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
1
+ import type { Params, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
2
+ import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
2
3
  import { LogOptions } from '../logger/core.js';
3
4
  export interface CreateResultArgs {
4
5
  ssr: boolean;
5
6
  legacyBuild: boolean;
6
7
  logging: LogOptions;
7
8
  origin: string;
8
- markdownRender: MarkdownRenderOptions;
9
+ markdown: MarkdownRenderingOptions;
9
10
  params: Params;
10
11
  pathname: string;
11
12
  renderers: SSRLoadedRenderer[];
@@ -117,7 +117,8 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
117
117
  const pathname = decodeURI(url.pathname);
118
118
  const rootRelativeUrl = pathname.substring(devRoot.length - 1);
119
119
  if (!buildingToSSR) {
120
- for (const [key] of url.searchParams) {
120
+ const allSearchParams = Array.from(url.searchParams);
121
+ for (const [key] of allSearchParams) {
121
122
  url.searchParams.delete(key);
122
123
  }
123
124
  }
@@ -26,7 +26,7 @@ var __objRest = (source, exclude) => {
26
26
  }
27
27
  return target;
28
28
  };
29
- import astroRemark from "@astrojs/markdown-remark";
29
+ import { renderMarkdown } from "@astrojs/markdown-remark";
30
30
  import { transform } from "@astrojs/compiler";
31
31
  import ancestor from "common-ancestor-path";
32
32
  import esbuild from "esbuild";
@@ -110,14 +110,13 @@ function markdown({ config }) {
110
110
  }
111
111
  if (id.endsWith(".md")) {
112
112
  const source = await fs.promises.readFile(id, "utf8");
113
- const render = astroRemark;
114
113
  const renderOpts = config.markdown;
115
114
  const filename = normalizeFilename(id);
116
115
  const fileUrl = new URL(`file://${filename}`);
117
116
  const isPage = fileUrl.pathname.startsWith(resolvePages(config).pathname);
118
117
  const hasInjectedScript = isPage && config._ctx.scripts.some((s) => s.stage === "page-ssr");
119
118
  const { data: frontmatter, content: markdownContent } = matter(source);
120
- let renderResult = await render(markdownContent, renderOpts);
119
+ let renderResult = await renderMarkdown(markdownContent, renderOpts);
121
120
  let { code: astroResult, metadata } = renderResult;
122
121
  const _a = frontmatter, { layout = "", components = "", setup = "" } = _a, content = __objRest(_a, ["layout", "components", "setup"]);
123
122
  content.astro = metadata;
package/env.d.ts CHANGED
@@ -4,8 +4,9 @@ type Astro = import('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
  /**
7
- * Astro.* available in all components
8
- * Docs: https://docs.astro.build/reference/api-reference/#astro-global
7
+ * Astro global available in all contexts in .astro files
8
+ *
9
+ * [Astro documentation](https://docs.astro.build/reference/api-reference/#astro-global)
9
10
  */
10
11
  declare const Astro: Readonly<Astro>;
11
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.8",
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",
@@ -76,14 +76,14 @@
76
76
  },
77
77
  "dependencies": {
78
78
  "@astrojs/compiler": "^0.14.1",
79
- "@astrojs/language-server": "^0.13.3",
80
- "@astrojs/markdown-remark": "^0.8.1",
79
+ "@astrojs/language-server": "^0.13.4",
80
+ "@astrojs/markdown-remark": "^0.8.2",
81
81
  "@astrojs/prism": "0.4.1",
82
82
  "@astrojs/webapi": "^0.11.0",
83
- "@babel/core": "^7.17.8",
84
- "@babel/generator": "^7.17.7",
85
- "@babel/parser": "^7.17.8",
86
- "@babel/traverse": "^7.17.3",
83
+ "@babel/core": "^7.17.9",
84
+ "@babel/generator": "^7.17.9",
85
+ "@babel/parser": "^7.17.9",
86
+ "@babel/traverse": "^7.17.9",
87
87
  "@proload/core": "^0.2.2",
88
88
  "@proload/plugin-tsm": "^0.1.1",
89
89
  "@web/parse5-utils": "^1.3.0",
@@ -94,12 +94,13 @@
94
94
  "debug": "^4.3.4",
95
95
  "diff": "^5.0.0",
96
96
  "eol": "^0.9.1",
97
- "es-module-lexer": "^0.10.4",
98
- "esbuild": "0.14.25",
97
+ "es-module-lexer": "^0.10.5",
98
+ "esbuild": "^0.14.34",
99
99
  "estree-walker": "^3.0.1",
100
100
  "execa": "^6.1.0",
101
101
  "fast-glob": "^3.2.11",
102
102
  "fast-xml-parser": "^4.0.7",
103
+ "gray-matter": "^4.0.3",
103
104
  "html-entities": "^2.3.3",
104
105
  "html-escaper": "^3.0.3",
105
106
  "htmlparser2": "^7.2.0",
@@ -120,7 +121,7 @@
120
121
  "rehype-slug": "^5.0.1",
121
122
  "resolve": "^1.22.0",
122
123
  "rollup": "^2.70.1",
123
- "semver": "^7.3.5",
124
+ "semver": "^7.3.6",
124
125
  "serialize-javascript": "^6.0.0",
125
126
  "shiki": "^0.10.1",
126
127
  "shorthash": "^0.0.2",
@@ -134,7 +135,7 @@
134
135
  "tsconfig-resolver": "^3.0.1",
135
136
  "vite": "^2.9.1",
136
137
  "yargs-parser": "^21.0.1",
137
- "zod": "^3.14.3"
138
+ "zod": "^3.14.4"
138
139
  },
139
140
  "devDependencies": {
140
141
  "@babel/types": "^7.17.0",
@@ -152,16 +153,17 @@
152
153
  "@types/mocha": "^9.1.0",
153
154
  "@types/parse5": "^6.0.3",
154
155
  "@types/path-browserify": "^1.0.0",
155
- "@types/prettier": "^2.4.4",
156
+ "@types/prettier": "^2.6.0",
156
157
  "@types/resolve": "^1.20.1",
157
158
  "@types/rimraf": "^3.0.2",
158
159
  "@types/send": "^0.17.1",
160
+ "@types/unist": "^2.0.6",
159
161
  "@types/yargs-parser": "^21.0.0",
160
162
  "astro-scripts": "workspace:*",
161
163
  "chai": "^4.3.6",
162
164
  "cheerio": "^1.0.0-rc.10",
163
165
  "mocha": "^9.2.2",
164
- "sass": "^1.49.11"
166
+ "sass": "^1.50.0"
165
167
  },
166
168
  "engines": {
167
169
  "node": "^14.15.0 || >=16.0.0",