Ariadocs

API reference

Edit on GitHub

Everything @ariadocs/mdx exports.

Functions

ExportSignature
createDocs(config) => DocsInstance
parseMdx(options) => Promise<ParseMdxResult>
serializeMdx(options) => Promise<SerializeMdxResult>
readMdx({ contentDir, slug }) => Promise<string>
getFrontmatter(options) => Promise<T>
getToc(options) => Promise<TocItem[]>
getNavigation({ contentDir }) => Promise<NavItem[]>
getPagePaths({ contentDir }) => Promise<string[]>
slugToTitle(slug) => string
isMdxNotFound(error) => boolean

options is either { contentDir, slug } or { source }, plus remarkPlugins, rehypePlugins, components and blockJs.

Components

ExportProps
MdxServersource, remarkPlugins, rehypePlugins, components, blockJs
MdxClientserialized, components

Errors

Errors are MdxError instances with a code:

CodeMeaning
MDX_NOT_FOUNDThe page doesn't exist
MDX_INVALID_SLUGThe slug points outside the content folder
MDX_INVALID_META_meta.json is invalid, or the frontmatter is JavaScript
MDX_COMPILE_ERRORserializeMdx couldn't compile the MDX, e.g. an unclosed tag