[]previous and next page

ShadowMdxOptions

Options of shadowMdx.

Options of shadowMdx.

Import#

ts
import type { ShadowMdxOptions } from "@shadow-js/vite/mdx";

Signature#

ts
interface ShadowMdxOptions {
  /** Files to compile, matched against the module id without its query string. Default `/\.mdx$/`. Add `.md` to read Markdown files too. */
  readonly include?: RegExp;
  /** Files to skip; checked first. Default: any path with a `node_modules` segment. */
  readonly exclude?: RegExp;
  /** Plugins of the Markdown syntax tree (`remark-frontmatter`, `remark-mdx-frontmatter`, `remark-gfm`, ...), as `@mdx-js/mdx` takes them. */
  readonly remarkPlugins?: readonly unknown[];
  /** Plugins of the HTML syntax tree (`rehype-slug`, `rehype-autolink-headings`, ...). */
  readonly rehypePlugins?: readonly unknown[];
  /** Plugins of the JavaScript syntax tree. They run before the plugin's own pass over the elements. */
  readonly recmaPlugins?: readonly unknown[];
  /**
   * How the elements of Markdown (`h1`, `p`, `a`, `code`, ...) are rendered.
   *
   * - `"overridable"`: each one is looked up in the `components` prop (and the provider), so an app can replace `a` or `h1`
   *   for every page. Each looked-up element is rendered by `Dynamic`.
   * - `"static"`: each one is a plain element in the page's template, cloned in one call. The `components` prop still
   *   supplies components the file names itself (`<Chart />`) and the `wrapper`, but cannot replace `h1` or `a`.
   *
   * Choose `"static"` for pages that never replace a Markdown element: documentation and blog posts render faster and ship
   * less code.
   * @default "overridable"
   */
  readonly elements?: "overridable" | "static";
  /** Options of `remark-rehype`. */
  readonly remarkRehypeOptions?: Readonly<Record<string, unknown>>;
  /**
   * A module that exports `useMDXComponents`, whose components every MDX file may use without a `components` prop (the
   * way `@mdx-js/react` works for React). Default: none; pass `components` to the file's component instead.
   */
  readonly providerImportSource?: string;
  /** `@mdx-js/mdx`, by module name, or your own `compile`. Default `"@mdx-js/mdx"`. */
  readonly mdx?: string | MdxCompile;
  /** Compiler plugins that run on the JSX of every MDX file (see `ShadowPluginOptions.plugins`). */
  readonly plugins?: readonly CompilerPlugin[];
  /** Module the compiled code imports its runtime helpers from. Default `"@shadow-js/web"` (`"@shadow-js/web/server"` for SSR). */
  readonly moduleName?: string;
}

Members#

Name Type Description
include? readonly include?: RegExp Files to compile, matched against the module id without its query string. Default /\.mdx$/. Add .md to read Markdown files too.
exclude? readonly exclude?: RegExp Files to skip; checked first. Default: any path with a node_modules segment.
remarkPlugins? readonly remarkPlugins?: readonly unknown[] Plugins of the Markdown syntax tree (remark-frontmatter, remark-mdx-frontmatter, remark-gfm, ...), as @mdx-js/mdx takes them.
rehypePlugins? readonly rehypePlugins?: readonly unknown[] Plugins of the HTML syntax tree (rehype-slug, rehype-autolink-headings, ...).
recmaPlugins? readonly recmaPlugins?: readonly unknown[] Plugins of the JavaScript syntax tree. They run before the plugin's own pass over the elements.
elements? readonly elements?: "overridable" | "static" How the elements of Markdown (h1, p, a, code, ...) are rendered. - "overridable": each one is looked up in the components prop (and the provider), so an app can replace a or h1 for every page. Each looked-up element is rendered by Dynamic. - "static": each one is a plain element in the page's template, cloned in one call. The components prop still supplies components the file names itself (<Chart />) and the wrapper, but cannot replace h1 or a. Choose "static" for pages that never replace a Markdown element: documentation and blog posts render faster and ship less code.
remarkRehypeOptions? readonly remarkRehypeOptions?: Readonly<Record<string, unknown>> Options of remark-rehype.
providerImportSource? readonly providerImportSource?: string A module that exports useMDXComponents, whose components every MDX file may use without a components prop (the way @mdx-js/react works for React). Default: none; pass components to the file's component instead.
mdx? readonly mdx?: string | MdxCompile @mdx-js/mdx, by module name, or your own compile. Default "@mdx-js/mdx".
plugins? readonly plugins?: readonly CompilerPlugin[] Compiler plugins that run on the JSX of every MDX file (see ShadowPluginOptions.plugins).
moduleName? readonly moduleName?: string Module the compiled code imports its runtime helpers from. Default "@shadow-js/web" ("@shadow-js/web/server" for SSR).