Home / Function/ mergeInternalContentIntoSections() — supabase Function Reference

mergeInternalContentIntoSections() — supabase Function Reference

Architecture documentation for the mergeInternalContentIntoSections() function in merge-internal-content.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  9acf4ce4_ed5f_e968_0b88_8392ea05a861["mergeInternalContentIntoSections()"]
  c6cc0226_3fb4_31f3_033d_a51f82782220["SideNavigation()"]
  c6cc0226_3fb4_31f3_033d_a51f82782220 -->|calls| 9acf4ce4_ed5f_e968_0b88_8392ea05a861
  a5ff300b_93e2_75db_5fa8_809a8ca0a579["getNavHrefsInSection()"]
  9acf4ce4_ed5f_e968_0b88_8392ea05a861 -->|calls| a5ff300b_93e2_75db_5fa8_809a8ca0a579
  style 9acf4ce4_ed5f_e968_0b88_8392ea05a861 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/learn/lib/merge-internal-content.ts lines 24–85

export function mergeInternalContentIntoSections(
  navItems: SidebarNavItem[],
  internalPaths: string[]
): SidebarNavItem[] {
  return navItems.map((parentItem) => {
    // If this item doesn't have children, return as is
    if (!parentItem.items) return parentItem

    // Get the section path (e.g., "/foundations" from parent href)
    const parentPath = parentItem.href
    if (!parentPath) return parentItem

    // Get all existing hrefs in this section
    const existingHrefs = getNavHrefsInSection(parentItem.items)

    // Find orphaned internal items that belong to this section
    const orphanedItems: SidebarNavItem[] = []

    internalPaths.forEach((internalPath) => {
      // Check if this internal path belongs to this parent section
      // e.g., /foundations/grafana belongs to /foundations
      if (internalPath.startsWith(parentPath + '/')) {
        // Check if there's no corresponding public item
        const publicPath = internalPath // e.g., /foundations/grafana
        if (!existingHrefs.has(publicPath)) {
          // Extract the title from the path
          const pathParts = internalPath.split('/').filter(Boolean)
          const fileName = pathParts[pathParts.length - 1]

          // Convert kebab-case to Title Case
          const title = fileName
            .split('-')
            .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
            .join(' ')

          orphanedItems.push({
            title,
            href: `/internal${internalPath}`,
            requiresAuth: true,
          })
        }
      }
    })

    // If there are orphaned items, add them to the end of this section with a heading
    if (orphanedItems.length > 0) {
      // Create a separator item for "Internal Resources"
      const internalResourcesHeading: SidebarNavItem = {
        title: 'Internal Resources',
        href: undefined,
        items: orphanedItems.sort((a, b) => a.title.localeCompare(b.title)),
      }

      return {
        ...parentItem,
        items: [...parentItem.items, internalResourcesHeading],
      }
    }

    return parentItem
  })
}

Subdomains

Called By

Frequently Asked Questions

What does mergeInternalContentIntoSections() do?
mergeInternalContentIntoSections() is a function in the supabase codebase.
What does mergeInternalContentIntoSections() call?
mergeInternalContentIntoSections() calls 1 function(s): getNavHrefsInSection.
What calls mergeInternalContentIntoSections()?
mergeInternalContentIntoSections() is called by 1 function(s): SideNavigation.

Analyze Your Own Codebase

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

Try Supermodel Free