Home / Function/ processMdx() — supabase Function Reference

processMdx() — supabase Function Reference

Architecture documentation for the processMdx() function in helpers.mdx.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  7920f0ed_264a_f954_6f8a_ec73ded46618["processMdx()"]
  eb1b33c7_935b_b61a_962a_2e11b76d01bc["fromFs()"]
  eb1b33c7_935b_b61a_962a_2e11b76d01bc -->|calls| 7920f0ed_264a_f954_6f8a_ec73ded46618
  c6ba9fcb_19c2_0847_332c_187b52d1c2d6["processMdx()"]
  c6ba9fcb_19c2_0847_332c_187b52d1c2d6 -->|calls| 7920f0ed_264a_f954_6f8a_ec73ded46618
  b22dcf14_357b_fbe2_4e4b_d47dbcf1b157["process()"]
  b22dcf14_357b_fbe2_4e4b_d47dbcf1b157 -->|calls| 7920f0ed_264a_f954_6f8a_ec73ded46618
  ba597464_635f_07d6_76dd_3978e7d83745["createHash()"]
  7920f0ed_264a_f954_6f8a_ec73ded46618 -->|calls| ba597464_635f_07d6_76dd_3978e7d83745
  8e785252_1103_5454_842f_d5c44fb39fd2["splitTreeBy()"]
  7920f0ed_264a_f954_6f8a_ec73ded46618 -->|calls| 8e785252_1103_5454_842f_d5c44fb39fd2
  eba6aa5b_17ba_040d_88a1_881371bdd96f["parseHeading()"]
  7920f0ed_264a_f954_6f8a_ec73ded46618 -->|calls| eba6aa5b_17ba_040d_88a1_881371bdd96f
  style 7920f0ed_264a_f954_6f8a_ec73ded46618 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/scripts/helpers.mdx.ts lines 36–84

async function processMdx(content: string, options?: { yaml?: boolean }): Promise<ProcessedMdx> {
  const checksum = await createHash(content)

  let frontmatter: Record<string, unknown> = {}
  if (options?.yaml) {
    const parsed = matter(content)
    frontmatter = parsed.data
    content = parsed.content
  }

  const mdxTree = fromMarkdown(content, {
    extensions: [mdxjs()],
    mdastExtensions: [mdxFromMarkdown()],
  })

  const sectionTrees = splitTreeBy(mdxTree, (node) => node.type === 'heading')

  const slugger = new GithubSlugger()

  const sections = sectionTrees.map((tree) => {
    const [firstNode] = tree.children
    const content = toMarkdown(tree, {
      extensions: [mdxToMarkdown()],
    })

    const rawHeading: string | undefined =
      firstNode.type === 'heading' ? toString(firstNode) : undefined

    if (!rawHeading) {
      return { content }
    }

    const { heading, customAnchor } = parseHeading(rawHeading)

    const slug = slugger.slug(customAnchor ?? heading)

    return {
      content,
      heading,
      slug,
    }
  })

  return {
    checksum,
    sections,
    meta: frontmatter,
  }
}

Subdomains

Frequently Asked Questions

What does processMdx() do?
processMdx() is a function in the supabase codebase.
What does processMdx() call?
processMdx() calls 3 function(s): createHash, parseHeading, splitTreeBy.
What calls processMdx()?
processMdx() is called by 3 function(s): fromFs, process, processMdx.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free