Skip to main content

starlight

Astro Starlight formatter for GraphQL documentation output.

Produces MDX compatible with Astro Starlight using its native Aside and Badge components. Includes lifecycle hooks for generating index files for each category directory.

const formatMDXPermalink: (id) => MDXString = formatMDXEscapedPermalink;

Defined in: starlight/index.ts:41

Formats a permalink for a section header, using the classic {#id} syntax escaped to remain valid MDX.

Starlight has no built-in custom header id syntax, so the permalink is inert unless a remark plugin such as remark-custom-heading-id is configured. Turn it off with docOptions.sectionHeaderId: false.

Formats a permalink for a section header using the classic {#id} syntax, escaped so that it stays valid MDX.

MDX parses an unescaped { as the start of an expression, and {#id} is not a valid one, so presets generating .mdx pages must use this variant.

Parameters​

id​

string

The ID of the section header

Returns​

MDXString

Formatted permalink string

Example​

formatMDXEscapedPermalink("my-id"); // \{#my-id\}

Param​

id

The ID of the section header

Returns​

Formatted permalink string


mdxDeclaration​

const mdxDeclaration: MDXString;

Defined in: starlight/index.ts:47

MDX import statement prepended to every generated file to register Starlight components.


mdxExtension​

const mdxExtension: ".mdx";

Defined in: starlight/index.ts:44

File extension used for generated pages.


createMDXFormatter()​

function createMDXFormatter(_meta?): Formatter;

Defined in: starlight/index.ts:100

Creates an Astro Starlight formatter.

Parameters​

_meta?​

Maybe<MetaInfo>

Unused metadata parameter

Returns​

Formatter

A complete Formatter implementation for Starlight MDX output


formatMDXAdmonition()​

function formatMDXAdmonition(admonition, _meta): MDXString;

Defined in: starlight/index.ts:69

Formats an admonition using the Starlight <Aside> component. Maps warning type to caution; all other types use note.

Parameters​

admonition​

AdmonitionType

Admonition data with text, title, and type

_meta​

Maybe<MetaInfo>

Unused metadata parameter

Returns​

MDXString

Formatted Starlight Aside component string


formatMDXBadge()​

function formatMDXBadge(badge): MDXString;

Defined in: starlight/index.ts:57

Formats a badge using the Starlight <Badge> component. Maps DEPRECATED classname to the caution variant; all others use default.

Parameters​

badge​

Badge

Badge data containing text and optional classname

Returns​

MDXString

Formatted Starlight Badge component string


function formatMDXLink(link): TypeLink;

Defined in: starlight/index.ts:83

Returns the link unchanged β€” Starlight routes page.mdx to page/ so links must not include the .mdx extension.

Parameters​

TypeLink

Link data with URL and text

Returns​

TypeLink

Unmodified link