mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 06:39:09 +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.
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { IS_PLATFORM } from 'common'
|
|
import { unstable_cache } from 'next/cache'
|
|
|
|
import { type NavMenuSection } from '~/components/Navigation/Navigation.types'
|
|
import Layout from '~/layouts/guides'
|
|
import { supabaseMisc } from '~/lib/supabaseMisc'
|
|
|
|
export default async function IntegrationsLayout({ children }: { children: React.ReactNode }) {
|
|
const additionalNavItems = { integrations: await getPartners() }
|
|
|
|
return <Layout additionalNavItems={additionalNavItems}>{children}</Layout>
|
|
}
|
|
|
|
// Will need to turn on revalidation later, just turning it off for now so we
|
|
// can slowly turn things back on while monitoring usage
|
|
const getPartners = unstable_cache(getPartnersImpl, [], { revalidate: false })
|
|
async function getPartnersImpl() {
|
|
if (!IS_PLATFORM) return []
|
|
|
|
const { data, error } = await supabaseMisc()
|
|
.from('partners')
|
|
.select('slug, title')
|
|
.eq('approved', true)
|
|
.eq('type', 'technology')
|
|
.order('title')
|
|
if (error) {
|
|
console.error(new Error('Error fetching partners', { cause: error }))
|
|
}
|
|
|
|
const partnerNavItems = (data ?? []).map(
|
|
(partner) =>
|
|
({
|
|
name: partner.title,
|
|
url: `https://supabase.com/partners/integrations/${partner.slug}` as `https://${string}`,
|
|
}) as Partial<NavMenuSection>
|
|
)
|
|
|
|
return partnerNavItems
|
|
}
|