Home / Function/ genGuidesStaticParams() — supabase Function Reference

genGuidesStaticParams() — supabase Function Reference

Architecture documentation for the genGuidesStaticParams() function in GuidesMdx.utils.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  f53ea99a_ed6b_f32f_a141_f991bb53a0a7["genGuidesStaticParams()"]
  88a9903a_7443_6d81_b2fe_c3606c9c278d["generateStaticParams()"]
  88a9903a_7443_6d81_b2fe_c3606c9c278d -->|calls| f53ea99a_ed6b_f32f_a141_f991bb53a0a7
  2ba77918_c71f_00b4_2b40_c0b152543573["join()"]
  f53ea99a_ed6b_f32f_a141_f991bb53a0a7 -->|calls| 2ba77918_c71f_00b4_2b40_c0b152543573
  040a5796_eb59_9ff7_60d0_b127fcaa25c2["map()"]
  f53ea99a_ed6b_f32f_a141_f991bb53a0a7 -->|calls| 040a5796_eb59_9ff7_60d0_b127fcaa25c2
  2a6ad195_f419_464c_aa6c_394e5f096b53["existsFile()"]
  f53ea99a_ed6b_f32f_a141_f991bb53a0a7 -->|calls| 2a6ad195_f419_464c_aa6c_394e5f096b53
  1673fedf_e2e8_e78f_d1bc_ea27d0b7b85a["checkGuidePageEnabled()"]
  f53ea99a_ed6b_f32f_a141_f991bb53a0a7 -->|calls| 1673fedf_e2e8_e78f_d1bc_ea27d0b7b85a
  style f53ea99a_ed6b_f32f_a141_f991bb53a0a7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/docs/GuidesMdx.utils.tsx lines 118–158

const genGuidesStaticParams = (directory?: string) => async () => {
  const promises = directory
    ? (await readdir(join(GUIDES_DIRECTORY, directory), { recursive: true }))
        .filter((file) => extname(file) === '.mdx' && !file.split(sep).at(-1)?.startsWith('_'))
        .map((file) => ({ slug: file.replace(/\.mdx$/, '').split(sep) }))
        .concat(
          (await existsFile(join(GUIDES_DIRECTORY, `${directory}.mdx`))) ? [{ slug: [] }] : []
        )
    : PUBLISHED_SECTIONS.map(async (section) =>
        (await readdir(join(GUIDES_DIRECTORY, section), { recursive: true }))
          .filter((file) => extname(file) === '.mdx' && !file.split(sep).at(-1)?.startsWith('_'))
          .map((file) => ({
            slug: [section, ...file.replace(/\.mdx$/, '').split(sep)],
          }))
          .concat(
            (await existsFile(join(GUIDES_DIRECTORY, `${section}.mdx`)))
              ? [{ slug: [section] }]
              : []
          )
      )

  // Flattening earlier will not work because there is nothing to flatten
  // until the promises resolve.
  const allParams = (await Promise.all(promises)).flat()

  /**
   * Filter out disabled pages from static generation
   */
  const enabledParams = allParams.filter((param) => {
    const guidesPath = `/guides/${directory ? `${directory}/` : ''}${param.slug.join('/')}`
    const isEnabled = checkGuidePageEnabled(guidesPath)

    if (!isEnabled) {
      console.log('Excluding disabled page from static generation: %s', guidesPath)
    }

    return isEnabled
  })

  return enabledParams
}

Subdomains

Frequently Asked Questions

What does genGuidesStaticParams() do?
genGuidesStaticParams() is a function in the supabase codebase.
What does genGuidesStaticParams() call?
genGuidesStaticParams() calls 4 function(s): checkGuidePageEnabled, existsFile, join, map.
What calls genGuidesStaticParams()?
genGuidesStaticParams() is called by 1 function(s): generateStaticParams.

Analyze Your Own Codebase

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

Try Supermodel Free