Home / Function/ getContent() — supabase Function Reference

getContent() — supabase Function Reference

Architecture documentation for the getContent() function in page.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  ab4f49e3_ca6f_6ee7_e6ce_c61c06858edc["getContent()"]
  a81c7658_9b4f_fc60_f8e0_789f62805e13["WrappersDocs()"]
  a81c7658_9b4f_fc60_f8e0_789f62805e13 -->|calls| ab4f49e3_ca6f_6ee7_e6ce_c61c06858edc
  1ed78735_5e48_6f4d_c7c0_7d9f2c098ee4["isValidGuideFrontmatter()"]
  ab4f49e3_ca6f_6ee7_e6ce_c61c06858edc -->|calls| 1ed78735_5e48_6f4d_c7c0_7d9f2c098ee4
  ed633091_0e4b_ed01_baa2_fe2bbb0be3f4["getLatestRelease()"]
  ab4f49e3_ca6f_6ee7_e6ce_c61c06858edc -->|calls| ed633091_0e4b_ed01_baa2_fe2bbb0be3f4
  569852a0_6fc2_34d0_9b3f_ea353f93379a["removeRedundantH1()"]
  ab4f49e3_ca6f_6ee7_e6ce_c61c06858edc -->|calls| 569852a0_6fc2_34d0_9b3f_ea353f93379a
  7f613770_e64b_8d47_0723_7692dd6947af["newEditLink()"]
  ab4f49e3_ca6f_6ee7_e6ce_c61c06858edc -->|calls| 7f613770_e64b_8d47_0723_7692dd6947af
  style ab4f49e3_ca6f_6ee7_e6ce_c61c06858edc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx lines 323–384

const getContent = async (params: Params) => {
  const federatedPage = pageMap.find(
    ({ slug }) => params && slug && params.slug && slug === params.slug.at(0)
  )

  let isExternal: boolean
  let meta: any
  let content: string
  let editLink: string
  let assetsBaseUrl: string = ''

  if (!federatedPage) {
    isExternal = false
    editLink = `supabase/supabase/apps/docs/content/guides/database/extensions/wrappers${params.slug?.length ? `/${params.slug.join('/')}` : ''}.mdx`
    const rawContent = await readFile(
      join(
        GUIDES_DIRECTORY,
        'database',
        'extensions',
        `wrappers${params.slug?.length ? `/${params.slug.join('/')}` : ''}.mdx`
      ),
      'utf-8'
    )
    ;({ data: meta, content } = matter(rawContent))
    if (!isValidGuideFrontmatter(meta)) {
      throw Error(`Expected valid frontmatter, got ${JSON.stringify(meta, null, 2)}`)
    }
  } else {
    isExternal = true
    let remoteFile: string
    ;({ remoteFile, meta } = federatedPage)

    const tag = await getLatestRelease()
    if (!tag) {
      throw new Error('No latest release found for federated wrappers pages')
    }

    const repoPath = `${org}/${repo}/${tag}/${docsDir}/${remoteFile}`
    editLink = `${org}/${repo}/blob/${tag}/${docsDir}/${remoteFile}`

    const response = await fetch(`https://raw.githubusercontent.com/${repoPath}`, {
      cache: 'force-cache',
      next: { tags: [REVALIDATION_TAGS.WRAPPERS] },
    })
    const rawContent = await response.text()

    assetsBaseUrl = `https://raw.githubusercontent.com/${org}/${repo}/${tag}/docs/assets/`

    const { content: contentWithoutFrontmatter } = matter(rawContent)
    content = removeRedundantH1(contentWithoutFrontmatter)
  }

  return {
    pathname:
      `/guides/database/extensions/wrappers${params.slug?.length ? `/${params.slug.join('/')}` : ''}` satisfies `/${string}`,
    isExternal,
    editLink: newEditLink(editLink),
    meta,
    content,
    assetsBaseUrl,
  }
}

Subdomains

Called By

Frequently Asked Questions

What does getContent() do?
getContent() is a function in the supabase codebase.
What does getContent() call?
getContent() calls 4 function(s): getLatestRelease, isValidGuideFrontmatter, newEditLink, removeRedundantH1.
What calls getContent()?
getContent() is called by 1 function(s): WrappersDocs.

Analyze Your Own Codebase

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

Try Supermodel Free