mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 03:15:06 +03:00
Split guide layouts by section, so that nav data fetches can be pushed down to thesection where they're actually used. Limits blast radius of any data fetch problems, and also lets us push down client components in the future, since layouts now have context on the request path and we don't need a high-level usePathname.
21 lines
700 B
TypeScript
21 lines
700 B
TypeScript
import { type NavMenuSection } from '~/components/Navigation/Navigation.types'
|
|
import Layout from '~/layouts/guides'
|
|
import { getAiPrompts } from '../getting-started/ai-prompts/[slug]/AiPrompts.utils'
|
|
|
|
export default async function GettingStartedLayout({ children }: { children: React.ReactNode }) {
|
|
const additionalNavItems = { prompts: await getPrompts() }
|
|
|
|
return <Layout additionalNavItems={additionalNavItems}>{children}</Layout>
|
|
}
|
|
|
|
async function getPrompts() {
|
|
const prompts = await getAiPrompts()
|
|
return prompts.map(
|
|
(prompt) =>
|
|
({
|
|
name: prompt.heading,
|
|
url: `/guides/getting-started/ai-prompts/${prompt.filename}`,
|
|
}) as Partial<NavMenuSection>
|
|
)
|
|
}
|