astro 1.0.0-beta.6 → 1.0.0-beta.9

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.9";
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,10 +1,9 @@
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";
5
4
  import { fileURLToPath } from "url";
6
5
  import { debug, info } from "../logger/core.js";
7
- import { prependForwardSlash } from "../../core/path.js";
6
+ import { prependForwardSlash, removeLeadingForwardSlash } from "../../core/path.js";
8
7
  import { BEFORE_HYDRATION_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
9
8
  import { call as callEndpoint } from "../endpoint/index.js";
10
9
  import { render } from "../render/core.js";
@@ -117,12 +116,12 @@ async function generatePath(pathname, opts, gopts) {
117
116
  }
118
117
  }
119
118
  const ssr = isBuildingToSSR(opts.astroConfig);
120
- const url = new URL(origin + pathname);
119
+ const url = new URL(opts.astroConfig.base + removeLeadingForwardSlash(pathname), origin);
121
120
  const options = {
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,
@@ -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.9";
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.9";
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.9"}`)} ${headline}`);
174
174
  }
175
175
  if (usage) {
176
176
  message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
package/dist/core/path.js CHANGED
@@ -4,9 +4,15 @@ function appendForwardSlash(path) {
4
4
  function prependForwardSlash(path) {
5
5
  return path[0] === "/" ? path : "/" + path;
6
6
  }
7
- function removeEndingForwardSlash(path) {
7
+ function removeTrailingForwardSlash(path) {
8
8
  return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
9
9
  }
10
+ function removeLeadingForwardSlash(path) {
11
+ return path.startsWith("/") ? path.substring(1) : path;
12
+ }
13
+ function trimSlashes(path) {
14
+ return path.replace(/^\/|\/$/g, "");
15
+ }
10
16
  function startsWithForwardSlash(path) {
11
17
  return path[0] === "/";
12
18
  }
@@ -30,15 +36,13 @@ function prependDotSlash(path) {
30
36
  }
31
37
  return "./" + path;
32
38
  }
33
- function trimSlashes(path) {
34
- return path.replace(/^\/|\/$/g, "");
35
- }
36
39
  export {
37
40
  appendForwardSlash,
38
41
  isRelativePath,
39
42
  prependDotSlash,
40
43
  prependForwardSlash,
41
- removeEndingForwardSlash,
44
+ removeLeadingForwardSlash,
45
+ removeTrailingForwardSlash,
42
46
  startsWithDotDotSlash,
43
47
  startsWithDotSlash,
44
48
  startsWithForwardSlash,
@@ -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
  });
package/dist/core/util.js CHANGED
@@ -4,7 +4,7 @@ import path from "path";
4
4
  import resolve from "resolve";
5
5
  import slash from "slash";
6
6
  import { fileURLToPath, pathToFileURL } from "url";
7
- import { removeEndingForwardSlash } from "./path.js";
7
+ import { removeTrailingForwardSlash } from "./path.js";
8
8
  function isObject(value) {
9
9
  return typeof value === "object" && value != null;
10
10
  }
@@ -24,7 +24,7 @@ function getOutputFilename(astroConfig, name) {
24
24
  if (astroConfig.build.format === "directory" && !STATUS_CODE_REGEXP.test(name)) {
25
25
  return path.posix.join(name, "index.html");
26
26
  }
27
- return `${removeEndingForwardSlash(name || "index")}.html`;
27
+ return `${removeTrailingForwardSlash(name || "index")}.html`;
28
28
  }
29
29
  function parseNpmName(spec) {
30
30
  if (!spec || spec[0] === "." || spec[0] === "/")
@@ -192,7 +192,7 @@ but ${plural ? "none were" : "it was not"} able to server-side render ${metadata
192
192
  Did you mean to enable ${formatList(probableRendererNames.map((r) => "`" + r + "`"))}?`);
193
193
  } else if (matchingRenderers.length === 1) {
194
194
  renderer = matchingRenderers[0];
195
- ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children));
195
+ ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children, metadata));
196
196
  } else {
197
197
  throw new Error(`Unable to render ${metadata.displayName}!
198
198
 
@@ -211,7 +211,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
211
211
  if (metadata.hydrate === "only") {
212
212
  html = await renderSlot(result, slots == null ? void 0 : slots.fallback);
213
213
  } else {
214
- ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children));
214
+ ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children, metadata));
215
215
  }
216
216
  }
217
217
  if (!html && typeof Component === "string") {
@@ -310,10 +310,22 @@ function defineScriptVars(vars) {
310
310
  }
311
311
  return markHTMLString(output);
312
312
  }
313
+ function getHandlerFromModule(mod, method) {
314
+ if (mod[method]) {
315
+ return mod[method];
316
+ }
317
+ if (method === "delete" && mod["del"]) {
318
+ return mod["del"];
319
+ }
320
+ if (mod["all"]) {
321
+ return mod["all"];
322
+ }
323
+ return void 0;
324
+ }
313
325
  async function renderEndpoint(mod, request, params) {
314
326
  var _a;
315
- const chosenMethod = ((_a = request.method) == null ? void 0 : _a.toLowerCase()) ?? "get";
316
- const handler = mod[chosenMethod];
327
+ const chosenMethod = (_a = request.method) == null ? void 0 : _a.toLowerCase();
328
+ const handler = getHandlerFromModule(mod, chosenMethod);
317
329
  if (!handler || typeof handler !== "function") {
318
330
  throw new Error(`Endpoint handler not found! Expected an exported function for "${chosenMethod}"`);
319
331
  }
@@ -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';
@@ -455,14 +455,23 @@ export interface AstroUserConfig {
455
455
  * ```
456
456
  */
457
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';
458
467
  /**
459
468
  * @docs
460
469
  * @name markdown.shikiConfig
461
- * @type {ShikiConfig}
470
+ * @typeraw {Partial<ShikiConfig>}
462
471
  * @description
463
472
  * Shiki configuration options. See [the markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage.
464
473
  */
465
- shikiConfig?: ShikiConfig;
474
+ shikiConfig?: Partial<ShikiConfig>;
466
475
  /**
467
476
  * @docs
468
477
  * @name markdown.syntaxHighlight
@@ -487,7 +496,7 @@ export interface AstroUserConfig {
487
496
  /**
488
497
  * @docs
489
498
  * @name markdown.remarkPlugins
490
- * @type {Plugin[]}
499
+ * @type {RemarkPlugins}
491
500
  * @description
492
501
  * Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built.
493
502
  *
@@ -502,11 +511,11 @@ export interface AstroUserConfig {
502
511
  * };
503
512
  * ```
504
513
  */
505
- remarkPlugins?: Plugin[];
514
+ remarkPlugins?: RemarkPlugins;
506
515
  /**
507
516
  * @docs
508
517
  * @name markdown.rehypePlugins
509
- * @type {Plugin[]}
518
+ * @type {RehypePlugins}
510
519
  * @description
511
520
  * Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built.
512
521
  *
@@ -521,7 +530,7 @@ export interface AstroUserConfig {
521
530
  * };
522
531
  * ```
523
532
  */
524
- rehypePlugins?: Plugin[];
533
+ rehypePlugins?: RehypePlugins;
525
534
  };
526
535
  /**
527
536
  * @name adapter
@@ -588,12 +597,12 @@ export interface AstroUserConfig {
588
597
  };
589
598
  experimental?: {
590
599
  /**
591
- * Enable experimental support for 3rd-party integrations.
600
+ * Enable support for 3rd-party integrations.
592
601
  * Default: false
593
602
  */
594
603
  integrations?: boolean;
595
604
  /**
596
- * Enable a build for SSR support.
605
+ * Enable support for 3rd-party SSR adapters.
597
606
  * Default: false
598
607
  */
599
608
  ssr?: boolean;
@@ -697,8 +706,6 @@ export declare type JSXTransformFn = (options: {
697
706
  export interface ManifestData {
698
707
  routes: RouteData[];
699
708
  }
700
- export declare type MarkdownRenderOptions = [string | MarkdownParser, Record<string, any>];
701
- export declare type MarkdownParser = (contents: string, options?: Record<string, any>) => MarkdownParserResponse | PromiseLike<MarkdownParserResponse>;
702
709
  export interface MarkdownParserResponse {
703
710
  frontmatter: {
704
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,9 +1,10 @@
1
1
  export declare function appendForwardSlash(path: string): string;
2
2
  export declare function prependForwardSlash(path: string): string;
3
- export declare function removeEndingForwardSlash(path: string): string;
3
+ export declare function removeTrailingForwardSlash(path: string): string;
4
+ export declare function removeLeadingForwardSlash(path: string): string;
5
+ export declare function trimSlashes(path: string): string;
4
6
  export declare function startsWithForwardSlash(path: string): boolean;
5
7
  export declare function startsWithDotDotSlash(path: string): boolean;
6
8
  export declare function startsWithDotSlash(path: string): boolean;
7
9
  export declare function isRelativePath(path: string): boolean;
8
10
  export declare function prependDotSlash(path: string): string;
9
- export declare function trimSlashes(path: string): string;
@@ -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[];
@@ -23,6 +23,7 @@ export declare function addAttribute(value: any, key: string, shouldEscape?: boo
23
23
  export declare function spreadAttributes(values: Record<any, any>, shouldEscape?: boolean): any;
24
24
  export declare function defineStyleVars(selector: string, vars: Record<any, any>): any;
25
25
  export declare function defineScriptVars(vars: Record<any, any>): any;
26
+ /** Renders an endpoint request to completion, returning the body. */
26
27
  export declare function renderEndpoint(mod: EndpointHandler, request: Request, params: Params): Promise<Response | import("../../@types/astro").EndpointOutput<string>>;
27
28
  export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
28
29
  export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<{
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.9",
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",
@@ -65,10 +65,19 @@
65
65
  "README.md",
66
66
  "vendor"
67
67
  ],
68
+ "scripts": {
69
+ "build": "astro-scripts build \"src/**/*.ts\" && tsc",
70
+ "build:ci": "astro-scripts build \"src/**/*.ts\"",
71
+ "dev": "astro-scripts dev \"src/**/*.ts\"",
72
+ "postbuild": "astro-scripts copy \"src/**/*.astro\"",
73
+ "benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
74
+ "test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
75
+ "test:match": "mocha --timeout 20000 -g"
76
+ },
68
77
  "dependencies": {
69
78
  "@astrojs/compiler": "^0.14.1",
70
79
  "@astrojs/language-server": "^0.13.4",
71
- "@astrojs/markdown-remark": "^0.8.1",
80
+ "@astrojs/markdown-remark": "^0.9.0",
72
81
  "@astrojs/prism": "0.4.1",
73
82
  "@astrojs/webapi": "^0.11.0",
74
83
  "@babel/core": "^7.17.9",
@@ -91,6 +100,7 @@
91
100
  "execa": "^6.1.0",
92
101
  "fast-glob": "^3.2.11",
93
102
  "fast-xml-parser": "^4.0.7",
103
+ "gray-matter": "^4.0.3",
94
104
  "html-entities": "^2.3.3",
95
105
  "html-escaper": "^3.0.3",
96
106
  "htmlparser2": "^7.2.0",
@@ -147,8 +157,9 @@
147
157
  "@types/resolve": "^1.20.1",
148
158
  "@types/rimraf": "^3.0.2",
149
159
  "@types/send": "^0.17.1",
160
+ "@types/unist": "^2.0.6",
150
161
  "@types/yargs-parser": "^21.0.0",
151
- "astro-scripts": "0.0.2",
162
+ "astro-scripts": "workspace:*",
152
163
  "chai": "^4.3.6",
153
164
  "cheerio": "^1.0.0-rc.10",
154
165
  "mocha": "^9.2.2",
@@ -157,15 +168,5 @@
157
168
  "engines": {
158
169
  "node": "^14.15.0 || >=16.0.0",
159
170
  "npm": ">=6.14.0"
160
- },
161
- "scripts": {
162
- "build": "astro-scripts build \"src/**/*.ts\" && tsc",
163
- "build:ci": "astro-scripts build \"src/**/*.ts\"",
164
- "dev": "astro-scripts dev \"src/**/*.ts\"",
165
- "postbuild": "astro-scripts copy \"src/**/*.astro\"",
166
- "benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
167
- "test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
168
- "test:match": "mocha --timeout 20000 -g"
169
- },
170
- "readme": "<a href=\"https://astro.build\">\n <img src=\"https://raw.githubusercontent.com/withastro/astro/main/assets/social/banner.svg\" />\n</a>\n\n<div center>\n\n**Astro** is a new kind of static site builder for the modern web&mdash;powerful developer experience meets lightweight output.\n\n</div>\n\n### [🚀 Read the launch post →](https://astro.build/blog/introducing-astro)\n\n### [📚 Learn Astro →](https://docs.astro.build/en/getting-started/)\n\n## Project Status\n\n⚠️ **Astro is still beta software&mdash;missing features and bugs are to be expected!** We are quickly working our way towards a stable, production-ready v1.0 release, but we are still finalizing some of Astro's APIs.\n\nThat being said, there are quite a few Astro sites in production already. We're incredibly grateful to everyone who has made an early bet on Astro!\n\n## Quick Start\n\n<table>\n <tbody>\n <tr>\n <td>\n <img width=\"441\" height=\"1px\">\n <strong>👾 Online</strong>\n </td>\n <td>\n <img width=\"441\" height=\"1px\">\n <strong>📦 Local</strong>\n </td>\n </tr>\n <tr>\n<td>\n\nTry Astro in your browser!\n\n[Launch astro.new →](https://astro.new)\n\n</td>\n<td>\n\nGet started with Astro using our interactive CLI!\n\n```bash\nnpm init astro my-astro-project\n```\n\n</td>\n </tr>\n </tbody>\n</table>\n\n## Sponsors\n\nYou can sponsor Astro's development on [Open Collective](https://opencollective.com/astrodotbuild). Astro is generously supported by the following companies and individuals:\n\n### Platinum Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\"><a href=\"https://www.netlify.com/#gh-light-mode-only\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify.svg#gh-light-mode-only\" alt=\"Netlify\" /></a><a href=\"https://www.netlify.com/#gh-dark-mode-only\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify-dark.svg#gh-dark-mode-only\" alt=\"Netlify\" />\n </a></td>\n <td align=\"center\"><a href=\"https://www.vercel.com/#gh-light-mode-only\" target=\"_blank\"><img width=\"150\" height=\"34\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel.svg#gh-light-mode-only\" alt=\"Vercel\" /></a><a href=\"https://www.vercel.com/#gh-dark-mode-only\"><img width=\"150\" height=\"34\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel-dark.svg#gh-dark-mode-only\" alt=\"Vercel\" />\n </a></td>\n </tr>\n </tbody>\n</table>\n\n### Gold Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\">\n <a href=\"https://divRIOTS.com#gh-light-mode-only\" target=\"_blank\">\n <img width=\"150\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots.svg#gh-light-mode-only\" alt=\"‹div›RIOTS\" />\n </a>\n <a href=\"https://divRIOTS.com#gh-dark-mode-only\" target=\"_blank\">\n <img width=\"150\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots-dark.svg#gh-dark-mode-only\" alt=\"‹div›RIOTS\" />\n </a>\n </td>\n <td align=\"center\">\n <a href=\"https://stackupdigital.co.uk/#gh-light-mode-only\" target=\"_blank\">\n <img width=\"162\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup.svg#gh-light-mode-only\" alt=\"StackUp Digital\" />\n </a>\n <a href=\"https://stackupdigital.co.uk/#gh-dark-mode-only\" target=\"_blank\">\n <img width=\"130\" height=\"32\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup-dark.svg#gh-dark-mode-only\" alt=\"StackUp Digital\" />\n </a>\n </td>\n </tr>\n </tbody>\n</table>\n\n### Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\"><a href=\"https://sentry.io\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/sentry.svg\" alt=\"Sentry\" /></a></td><td align=\"center\"><a href=\"https://qoddi.com\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://devcenter.qoddi.com/wp-content/uploads/2021/11/blog-transparent-logo-1.png\" alt=\"Qoddi App Platform\" /></a></td>\n </tr>\n </tbody>\n</table>\n"
171
- }
171
+ }
172
+ }
package/LICENSE DELETED
@@ -1,34 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Fred K. Schott
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
-
24
- """
25
- This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
26
-
27
- Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
28
-
29
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
30
-
31
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
32
-
33
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
- """