Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

more optimizing

Jonathan Summers-Muir9bad9a7f0e6e
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
index db10c1d02b0..e40f2e99e53 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
@@ -192,14 +192,14 @@ const SideNav = () => {
<NavigationMenuGuideList id={'integrations'} active={isIntegrationsActive} />
<NavigationMenuGuideList id={'reference'} active={isReferenceActive} />
{/* // Client Libs */}
- <NavigationMenuRefList
+ {/* <NavigationMenuRefList
key={'reference-js-menu'}
id={'reference_javascript_v1'}
active={isReference_Javascript_V1}
commonSections={libCommonSections}
lib="javascript"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_js_v1)}
- />
+ /> */}
<NavigationMenuRefList
key={'reference-js-menu'}
id={'reference_javascript_v2'}
@@ -208,59 +208,59 @@ const SideNav = () => {
lib="javascript"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_js_v2)}
/>
- <NavigationMenuRefList
+ {/* <NavigationMenuRefList
key={'reference-dart-menu'}
id={'reference_dart_v0'}
active={isReference_Dart_V0}
commonSections={libCommonSections}
lib="dart"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_dart_v0)}
- />
- <NavigationMenuRefList
+ /> */}
+ {/* <NavigationMenuRefList
key={'reference-dart-menu'}
id={'reference_dart_v1'}
active={isReference_Dart_V1}
commonSections={libCommonSections}
lib="dart"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_dart_v1)}
- />
+ /> */}
{/* // Tools */}
- <NavigationMenuRefList
+ {/* <NavigationMenuRefList
key={'reference-cli-menu'}
id={'reference_cli'}
active={isReference_Cli}
commonSections={cliCommonSections}
lib="cli"
- />
- <NavigationMenuRefList
+ /> */}
+ {/* <NavigationMenuRefList
key={'reference-api-menu'}
id={'reference_api'}
active={isReference_Api}
commonSections={apiCommonSections}
lib="api"
- />
+ /> */}
{/* // Self Hosting Server */}
- <NavigationMenuRefList
+ {/* <NavigationMenuRefList
key={'reference-self-hosting-auth-menu'}
id={'reference_self_hosting_auth'}
active={isReference_Self_Hosting_Auth}
commonSections={authServerCommonSections}
lib="self-hosting-auth"
- />
- <NavigationMenuRefList
+ /> */}
+ {/* <NavigationMenuRefList
key={'reference-self-hosting-storage-menu'}
id={'reference_self_hosting_storage'}
active={isReference_Self_Hosting_Storage}
commonSections={storageServerCommonSections}
lib="self-hosting-storage"
- />
- <NavigationMenuRefList
+ /> */}
+ {/* <NavigationMenuRefList
key={'reference-self-hosting-realtime-menu'}
id={'reference_self_hosting_realtime'}
active={isReference_Self_Hosting_Realtime}
commonSections={realtimeServerCommonSections}
lib="self-hosting-auth"
- />
+ /> */}
</div>
)
}
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
index d680ecc3dcb..2800ff25557 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
@@ -1,11 +1,7 @@
-import { useTheme } from 'common/Providers'
-import Image from 'next/image'
-import Link from 'next/link'
+import * as Accordion from '@radix-ui/react-accordion'
import { useRouter } from 'next/router'
import React from 'react'
-import { IconChevronLeft } from '~/../../packages/ui'
-import * as NavItems from './NavigationMenu.constants'
-import * as Accordion from '@radix-ui/react-accordion'
+import NavigationMenuGuideListItems from './NavigationMenuGuideListItems'
interface Props {
id: string
@@ -13,9 +9,6 @@ interface Props {
}
const NavigationMenuGuideList: React.FC<Props> = ({ id, active }) => {
const router = useRouter()
- const { isDarkMode } = useTheme()
-
- const menu = NavItems[id]
// get url
const url = router.asPath
@@ -39,186 +32,7 @@ const NavigationMenuGuideList: React.FC<Props> = ({ id, active }) => {
!active ? 'opacity-0 invisible absolute' : '',
].join(' ')}
>
- <ul className={['relative w-full flex flex-col gap-0'].join(' ')}>
- <Link href={`${menu.parent ?? '/'}`} passHref>
- <a
- className={[
- 'flex items-center gap-1 text-xs group mb-3',
- 'text-base transition-all duration-200 text-brand-900 hover:text-brand-1200 hover:cursor-pointer ',
- ].join(' ')}
- >
- <div className="relative w-2">
- <div className="transition-all ease-out ml-0 group-hover:-ml-1">
- <IconChevronLeft size={10} strokeWidth={3} />
- </div>
- </div>
- <span>Back to Home</span>
- </a>
- </Link>
-
- <Link href={menu.url ?? ''} passHref>
- <a>
- <div className="flex items-center gap-3 my-3">
- <Image
- alt={menu.icon}
- width={15}
- height={15}
- src={
- `${router.basePath}` +
- `/img/icons/menu/${menu.icon}${isDarkMode ? '' : '-light'}.svg`
- }
- />
- {/* </div> */}
- <span
- className={[
- ' ',
- !menu.title && 'capitalize',
- menu.url === router.pathname
- ? 'text-brand-900'
- : 'hover:text-brand-900 text-scale-1200',
- ].join(' ')}
- >
- {menu.title ?? id}
- </span>
- </div>
- </a>
- </Link>
-
- {menu.items.map((x, index) => {
- // console.log('1st type of link?', x.items && x.items.length > 0)
- // console.log()
- return (
- <div key={x.url}>
- {x.items && x.items.length > 0 ? (
- <div>
- {x.items.map((subItem, subItemIndex) => {
- // console.log('subitem', { subItem })
- // console.log('router', router)
- //console.log('subitem url', subItem.url)
- let subItemMenuOpen = false
-
- if (router.asPath.includes(subItem.url)) {
- subItemMenuOpen = true
- }
-
- const LinkContainer = (props) => {
- return (
- <Link href={props.url} passHref>
- <a className={props.className}>{props.children}</a>
- </Link>
- )
- }
-
- return (
- <>
- {subItemIndex === 0 && (
- <>
- <div className="h-px w-full bg-green-500 my-3"></div>
- <span className="font-mono text-xs uppercase text-scale-1200 font-medium tracking-wider">
- {x.name}
- </span>
- </>
- )}
- <Accordion.Item key={subItem.label} value={subItem.url}>
- <li key={subItem.name}>
- <LinkContainer
- url={subItem.url}
- className={[
- 'flex items-center gap-2',
- 'cursor-pointer transition text-sm',
- subItem.url === router.pathname
- ? 'text-brand-900'
- : 'hover:text-brand-900 text-scale-1000',
- ].join(' ')}
- parent={subItem.parent}
- >
- {subItem.icon && (
- <Image
- alt={subItem.name + router.basePath}
- src={
- `${router.basePath}` +
- `${subItem.icon}${!isDarkMode ? '-light' : ''}.svg`
- }
- width={15}
- height={15}
- />
- )}
- {subItem.name}
- </LinkContainer>
- </li>
-
- {subItem.items && subItem.items.length > 0 && (
- <Accordion.Content className="transition data-open:animate-slide-down data-closed:animate-slide-up ml-2">
- {subItem.items.map((subSubItem, subSubItemIndex) => {
- return (
- <li key={subItem.name}>
- <Link href={`${subSubItem.url}`} passHref>
- <a
- className={[
- 'cursor-pointer transition text-sm',
- subSubItem.url === router.pathname
- ? 'text-brand-900'
- : 'hover:text-brand-900 text-scale-1000',
- ].join(' ')}
- >
- {subSubItem.name}
- </a>
- </Link>
- </li>
- )
- })}
- </Accordion.Content>
- )}
- </Accordion.Item>
- </>
- )
- })}
- </div>
- ) : (
- <>
- <li>
- <Link href={`${x.url}`} passHref>
- <a
- className={[
- 'cursor-pointer transition text-sm',
- x.url === router.pathname
- ? 'text-brand-900'
- : 'hover:text-brand-900 text-scale-1000',
- ].join(' ')}
- >
- {x.icon && <img className="w-3" src={`${router.basePath}${x.icon}`} />}
- {x.name}
- </a>
- </Link>
- </li>
- </>
- )}
- </div>
- )
- })}
- {menu.extras && (
- <>
- <div className="h-px w-full bg-green-500 my-3"></div>
- <span className="font-mono text-xs uppercase text-scale-1200 font-medium tracking-wider mb-2">
- Resources
- </span>
- </>
- )}
- {menu.extras?.map((x) => {
- return (
- <div key={x.name}>
- <li>
- <Link href={`${x.href}`} passHref>
- <a className="cursor-pointer transition text-scale-1100 text-sm hover:text-brand-900 flex gap-3 my-1">
- {x.icon && <img className="w-4" src={`${router.basePath}${x.icon}`} />}
- {x.name}
- </a>
- </Link>
- </li>
- </div>
- )
- })}
- </ul>
+ <NavigationMenuGuideListItems id={id} />
</Accordion.Root>
)
}
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideListItems.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideListItems.tsx
new file mode 100644
index 00000000000..ebcc68d1a75
--- /dev/null
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideListItems.tsx
@@ -0,0 +1,201 @@
+import { useTheme } from 'common/Providers'
+import Image from 'next/image'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import React from 'react'
+import { IconChevronLeft } from '~/../../packages/ui'
+import * as NavItems from './NavigationMenu.constants'
+import * as Accordion from '@radix-ui/react-accordion'
+
+const Content = ({ id }) => {
+ const router = useRouter()
+ const { isDarkMode } = useTheme()
+
+ const menu = NavItems[id]
+
+ return (
+ <ul className={['relative w-full flex flex-col gap-0'].join(' ')}>
+ {console.log(id && 'GUIDE MENU id changed')}
+ <Link href={`${menu.parent ?? '/'}`} passHref>
+ <a
+ className={[
+ 'flex items-center gap-1 text-xs group mb-3',
+ 'text-base transition-all duration-200 text-brand-900 hover:text-brand-1200 hover:cursor-pointer ',
+ ].join(' ')}
+ >
+ <div className="relative w-2">
+ <div className="transition-all ease-out ml-0 group-hover:-ml-1">
+ <IconChevronLeft size={10} strokeWidth={3} />
+ </div>
+ </div>
+ <span>Back to Home</span>
+ </a>
+ </Link>
+
+ <Link href={menu.url ?? ''} passHref>
+ <a>
+ <div className="flex items-center gap-3 my-3">
+ <Image
+ alt={menu.icon}
+ width={15}
+ height={15}
+ src={
+ `${router.basePath}` +
+ `/img/icons/menu/${menu.icon}${isDarkMode ? '' : '-light'}.svg`
+ }
+ />
+ {/* </div> */}
+ <span
+ className={[
+ ' ',
+ !menu.title && 'capitalize',
+ menu.url === router.pathname
+ ? 'text-brand-900'
+ : 'hover:text-brand-900 text-scale-1200',
+ ].join(' ')}
+ >
+ {menu.title ?? id}
+ </span>
+ </div>
+ </a>
+ </Link>
+
+ {menu.items.map((x, index) => {
+ // console.log('1st type of link?', x.items && x.items.length > 0)
+ // console.log()
+ return (
+ <div key={x.url}>
+ {x.items && x.items.length > 0 ? (
+ <div>
+ {x.items.map((subItem, subItemIndex) => {
+ // console.log('subitem', { subItem })
+ // console.log('router', router)
+ //console.log('subitem url', subItem.url)
+ let subItemMenuOpen = false
+
+ if (router.asPath.includes(subItem.url)) {
+ subItemMenuOpen = true
+ }
+
+ const LinkContainer = (props) => {
+ return (
+ <Link href={props.url} passHref>
+ <a className={props.className}>{props.children}</a>
+ </Link>
+ )
+ }
+
+ return (
+ <>
+ {subItemIndex === 0 && (
+ <>
+ <div className="h-px w-full bg-green-500 my-3"></div>
+ <span className="font-mono text-xs uppercase text-scale-1200 font-medium tracking-wider">
+ {x.name}
+ </span>
+ </>
+ )}
+ <Accordion.Item key={subItem.label} value={subItem.url}>
+ <li key={subItem.name}>
+ <LinkContainer
+ url={subItem.url}
+ className={[
+ 'flex items-center gap-2',
+ 'cursor-pointer transition text-sm',
+ subItem.url === router.pathname
+ ? 'text-brand-900'
+ : 'hover:text-brand-900 text-scale-1000',
+ ].join(' ')}
+ parent={subItem.parent}
+ >
+ {subItem.icon && (
+ <Image
+ alt={subItem.name + router.basePath}
+ src={
+ `${router.basePath}` +
+ `${subItem.icon}${!isDarkMode ? '-light' : ''}.svg`
+ }
+ width={15}
+ height={15}
+ />
+ )}
+ {subItem.name}
+ </LinkContainer>
+ </li>
+
+ {subItem.items && subItem.items.length > 0 && (
+ <Accordion.Content className="transition data-open:animate-slide-down data-closed:animate-slide-up ml-2">
+ {subItem.items.map((subSubItem, subSubItemIndex) => {
+ return (
+ <li key={subItem.name}>
+ <Link href={`${subSubItem.url}`} passHref>
+ <a
+ className={[
+ 'cursor-pointer transition text-sm',
+ subSubItem.url === router.pathname
+ ? 'text-brand-900'
+ : 'hover:text-brand-900 text-scale-1000',
+ ].join(' ')}
+ >
+ {subSubItem.name}
+ </a>
+ </Link>
+ </li>
+ )
+ })}
+ </Accordion.Content>
+ )}
+ </Accordion.Item>
+ </>
+ )
+ })}
+ </div>
+ ) : (
+ <>
+ <li>
+ <Link href={`${x.url}`} passHref>
+ <a
+ className={[
+ 'cursor-pointer transition text-sm',
+ x.url === router.pathname
+ ? 'text-brand-900'
+ : 'hover:text-brand-900 text-scale-1000',
+ ].join(' ')}
+ >
+ {x.icon && <img className="w-3" src={`${router.basePath}${x.icon}`} />}
+ {x.name}
+ </a>
+ </Link>
+ </li>
+ </>
+ )}
+ </div>
+ )
+ })}
+ {menu.extras && (
+ <>
+ <div className="h-px w-full bg-green-500 my-3"></div>
+ <span className="font-mono text-xs uppercase text-scale-1200 font-medium tracking-wider mb-2">
+ Resources
+ </span>
+ </>
+ )}
+ {menu.extras?.map((x) => {
+ return (
+ <div key={x.name}>
+ <li>
+ <Link href={`${x.href}`} passHref>
+ <a className="cursor-pointer transition text-scale-1100 text-sm hover:text-brand-900 flex gap-3 my-1">
+ {x.icon && <img className="w-4" src={`${router.basePath}${x.icon}`} />}
+ {x.name}
+ </a>
+ </Link>
+ </li>
+ </div>
+ )
+ })}
+ </ul>
+ )
+}
+
+export default React.memo(Content)
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
index 908c55ee475..b1ae0480dfd 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
@@ -13,64 +13,9 @@ import { useTheme } from 'common/Providers'
import RevVersionDropdown from '~/components/RefVersionDropdown'
import { useMenuActiveRefId, useMenuLevelId } from '~/hooks/useMenuState'
import { RefIdOptions, RefKeyOptions } from './NavigationMenu'
+import NavigationMenuRefListItems from './NavigationMenuRefListItems'
-const FunctionLink = ({
- title,
- id,
- icon,
- library,
- slug,
-}: {
- title: string
- name?: string
- id: string
- icon?: string
- product?: string
- library: string
- slug: string
-}) => {
- const router = useRouter()
- const activeAccordianItem = useMenuActiveRefId()
-
- // check if we're on a versioned page
- let version = ''
- if (router.asPath.includes('v1')) {
- version = 'v1'
- }
-
- if (router.asPath.includes('v0')) {
- version = 'v0'
- }
-
- const active = activeAccordianItem === id
- return (
- <li key={id} className="function-link-item">
- <Link href={`/reference/${library}/${version ? version + '/' : ''}${slug}`} passHref>
- <a
- className={[
- 'cursor-pointer transition text-sm hover:text-brand-900 flex gap-3',
- active ? 'text-brand-900' : 'text-scale-1000',
- ].join(' ')}
- >
- {icon && <Image width={16} height={16} alt={icon} src={`${router.basePath}${icon}`} />}
- {title}
- </a>
- </Link>
- </li>
- )
-}
-
-const SideMenuTitle = ({ title }: { title: string }) => {
- return (
- <span className="font-mono text-xs uppercase text-scale-1200 font-medium tracking-wider mb-3">
- {title}
- </span>
- )
-}
-
-const Divider = () => {
- return <div className="h-px w-full bg-blackA-300 dark:bg-whiteA-300 my-3"></div>
-}
+import React from 'react'
interface INavigationMenuRefList {
id: RefIdOptions
@@ -90,62 +35,10 @@ const NavigationMenuRefList: React.FC<INavigationMenuRefList> = ({
allowedClientKeys,
active,
}) => {
- const router = useRouter()
- const { isDarkMode } = useTheme()
-
- let sections = commonSections
-
- const allowedKeys = allowedClientKeys
-
- if (!sections) console.error('no common sections imported')
-
- const menu = NavItems[id]
-
- const databaseFunctions = find(sections, { title: 'Database' })
- ? find(sections, { title: 'Database' }).items
- : []
-
- const authFunctions = find(sections, { title: 'Auth' })
- ? find(sections, { title: 'Auth' }).items
- : []
-
- const filterIds =
- databaseFunctions.length > 0
- ? find(databaseFunctions, {
- id: 'using-filters',
- }) &&
- find(databaseFunctions, {
- id: 'using-filters',
- })
- .items.filter((x) => allowedKeys.includes(x.id))
- .map((x) => x.id)
- : []
- const modifierIds =
- databaseFunctions.length > 0
- ? find(databaseFunctions, {
- id: 'using-modifiers',
- }) &&
- find(databaseFunctions, {
- id: 'using-modifiers',
- })
- .items.filter((x) => allowedKeys.includes(x.id))
- .map((x) => x.id)
- : []
-
- const authServerIds =
- databaseFunctions.length > 0
- ? find(authFunctions, {
- id: 'admin-api',
- }) &&
- find(authFunctions, {
- id: 'admin-api',
- }).items.map((x) => x.id)
- : []
-
// console.log(filterIds)
// console.log(modifierIds)
- const level = useMenuLevelId()
+ // const level = useMenuLevelId()
return (
<div
@@ -160,150 +53,14 @@ const NavigationMenuRefList: React.FC<INavigationMenuRefList> = ({
!active ? 'opacity-0 invisible absolute h-0 overflow-hidden' : '',
].join(' ')}
>
- <div className={'w-full flex flex-col gap-0 sticky top-8'}>
- <Link href="/" passHref>
- <a
- className={[
- 'flex items-center gap-1 text-xs group mb-3',
- 'text-base transition-all duration-200 text-scale-1100 hover:text-brand-1200 hover:cursor-pointer ',
- ].join(' ')}
- >
- <div className="relative w-2">
- <div className="transition-all ease-out ml-0 group-hover:-ml-1">
- <IconChevronLeft size={10} strokeWidth={3} />
- </div>
- </div>
- <span>Back to Main Menu</span>
- </a>
- </Link>
-
- <div className="flex items-center gap-3 my-3">
- <Image
- alt={id}
- width={24}
- height={24}
- src={`${router.basePath}/img/icons/menu/${menu.icon}${isDarkMode ? '' : '-light'}.svg`}
- className="rounded"
- />
- <span className={['text-base text-brand-1200 ', !menu.title && 'capitalize'].join(' ')}>
- {menu.title}
- </span>
- <RevVersionDropdown />
- </div>
- {/* )} */}
-
- <ul className="function-link-list">
- {sections.map((fn: any, fnIndex) => {
- //
- // check if the link is allowed to be displayed
- function isFuncNotInLibraryOrVersion(id, type) {
- if (id && allowedKeys && !allowedKeys.includes(id) && type !== 'markdown') {
- /*
- * Remove this menu link from side bar, as it does not exist for either
- * this language, or for this lib version
- *
- * */
- return true
- } else {
- return false
- }
- }
-
- // run allow check
- if (isFuncNotInLibraryOrVersion(fn.id, fn.type)) {
- return <></>
- }
-
- const RenderLink = (props) => {
- const activeAccordianItem = useMenuActiveRefId()
- let active = false
-
- const isFilter =
- filterIds && filterIds.length > 0 && filterIds.includes(activeAccordianItem)
- const isModifier =
- modifierIds && modifierIds.length > 0 && modifierIds.includes(activeAccordianItem)
- const isAuthServer =
- authServerIds &&
- authServerIds.length > 0 &&
- authServerIds.includes(activeAccordianItem)
-
- if (
- (isFilter && !isModifier && !isAuthServer && props.id === 'using-filters') ||
- (activeAccordianItem === 'using-filters' && props.id === 'using-filters')
- ) {
- active = true
- } else if (
- (isModifier && !isFilter && !isAuthServer && props.id === 'using-modifiers') ||
- (activeAccordianItem === 'using-modifiers' && props.id === 'using-modifiers')
- ) {
- active = true
- } else if (
- (isAuthServer && !isFilter && !isModifier && props.id === 'admin-api') ||
- (activeAccordianItem === 'admin-api' && props.id === 'admin-api')
- ) {
- active = true
- } else {
- active = false
- }
-
- return (
- <Accordion.Root
- collapsible
- key={props.id + '-accordian-root-for-func-' + fnIndex}
- type="single"
- value={active ? props.id : ''}
- >
- <Accordion.Item key={props.id + '-accordian-item'} value={props.id}>
- <FunctionLink {...props} library={lib} />
- <Accordion.Content
- key={props.id + '-sub-items-accordion-container'}
- className="transition data-open:animate-slide-down data-closed:animate-slide-up ml-2"
- >
- {props.items &&
- props.items
- .filter((item) => allowedKeys.includes(item.id))
- .map((item) => {
- return <FunctionLink {...item} library={lib} />
- })}
- </Accordion.Content>
- </Accordion.Item>
- </Accordion.Root>
- )
- }
-
- // handle subtitles with subitems
- if (!fn.id) {
- return (
- <>
- <Divider />
- <SideMenuTitle title={fn.title} />
- {fn.items &&
- fn.items
- //.filter((item) => item.libs && item.libs.includes(lib))
- .map((item) => {
- // run allow check
- if (isFuncNotInLibraryOrVersion(item.id, item.type)) return <></>
- return <RenderLink {...item} library={menu.title} />
- })}
- </>
- )
- } else {
- // handle normal links
- return (
- <>
- <RenderLink {...fn} library={menu.title} />
- {fn.items &&
- fn.items
- //.filter((item) => item.libs.includes(lib))
- .map((item) => <RenderLink {...item} library={menu.title} />)}
- </>
- )
- }
- })}
- </ul>
- </div>
+ <NavigationMenuRefListItems
+ id={id}
+ lib={lib}
+ commonSections={commonSections}
+ allowedClientKeys={allowedClientKeys}
+ />
</div>
)
}
-export default NavigationMenuRefList
+export default React.memo(NavigationMenuRefList)
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx
new file mode 100644
index 00000000000..bda02438afc
--- /dev/null
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx
@@ -0,0 +1,299 @@
+import * as Accordion from '@radix-ui/react-accordion'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import { IconChevronLeft } from 'ui'
+import * as NavItems from './NavigationMenu.constants'
+
+import { find } from 'lodash'
+import Image from 'next/image'
+import { useTheme } from 'common/Providers'
+
+import RevVersionDropdown from '~/components/RefVersionDropdown'
+// import { useMenuActiveRefId } from '~/hooks/useMenuState'
+import { RefIdOptions, RefKeyOptions } from './NavigationMenu'
+
+import React from 'react'
+
+const FunctionLink = ({
+ title,
+ id,
+ icon,
+ library,
+ slug,
+}: {
+ title: string
+ name?: string
+ id: string
+ icon?: string
+ product?: string
+ library: string
+ slug: string
+}) => {
+ const router = useRouter()
+ const activeAccordianItem = '1' // useMenuActiveRefId()
+
+ // check if we're on a versioned page
+ let version = ''
+ if (router.asPath.includes('v1')) {
+ version = 'v1'
+ }
+
+ if (router.asPath.includes('v0')) {
+ version = 'v0'
+ }
+
+ const active = activeAccordianItem === id
+ return (
+ <li key={id} className="function-link-item">
+ <Link href={`/reference/${library}/${version ? version + '/' : ''}${slug}`} passHref>
+ <a
+ className={[
+ 'cursor-pointer transition text-sm hover:text-brand-900 flex gap-3',
+ active ? 'text-brand-900' : 'text-scale-1000',
+ ].join(' ')}
+ >
+ {icon && <Image width={16} height={16} alt={icon} src={`${router.basePath}${icon}`} />}
+ {title}
+ </a>
+ </Link>
+ </li>
+ )
+}
+
+const SideMenuTitle = ({ title }: { title: string }) => {
+ return (
+ <span className="font-mono text-xs uppercase text-scale-1200 font-medium tracking-wider mb-3">
+ {title}
+ </span>
+ )
+}
+
+const Divider = () => {
+ return <div className="h-px w-full bg-blackA-300 dark:bg-whiteA-300 my-3"></div>
+}
+
+interface INavigationMenuRefList {
+ id: RefIdOptions
+ lib: RefKeyOptions
+ commonSections: any[] // to do type up
+
+ // the keys of menu items that are allowed to be shown on the side menu
+ // if undefined, we show all the menu items
+ allowedClientKeys?: string[]
+}
+
+const Content: React.FC<INavigationMenuRefList> = ({
+ id,
+ lib,
+ commonSections,
+ allowedClientKeys,
+}) => {
+ const router = useRouter()
+ const { isDarkMode } = useTheme()
+
+ console.log(
+ id && 'id changed',
+ lib && 'lib changed',
+ commonSections && 'commonSections changed',
+ allowedClientKeys && 'allowedClientKeys changed'
+ )
+
+ let sections = commonSections
+
+ const allowedKeys = allowedClientKeys
+
+ if (!sections) console.error('no common sections imported')
+
+ const menu = NavItems[id]
+
+ const databaseFunctions = find(sections, { title: 'Database' })
+ ? find(sections, { title: 'Database' }).items
+ : []
+
+ const authFunctions = find(sections, { title: 'Auth' })
+ ? find(sections, { title: 'Auth' }).items
+ : []
+
+ const filterIds =
+ databaseFunctions.length > 0
+ ? find(databaseFunctions, {
+ id: 'using-filters',
+ }) &&
+ find(databaseFunctions, {
+ id: 'using-filters',
+ })
+ .items.filter((x) => allowedKeys.includes(x.id))
+ .map((x) => x.id)
+ : []
+ const modifierIds =
+ databaseFunctions.length > 0
+ ? find(databaseFunctions, {
+ id: 'using-modifiers',
+ }) &&
+ find(databaseFunctions, {
+ id: 'using-modifiers',
+ })
+ .items.filter((x) => allowedKeys.includes(x.id))
+ .map((x) => x.id)
+ : []
+
+ const authServerIds =
+ databaseFunctions.length > 0
+ ? find(authFunctions, {
+ id: 'admin-api',
+ }) &&
+ find(authFunctions, {
+ id: 'admin-api',
+ }).items.map((x) => x.id)
+ : []
+
+ // console.log(filterIds)
+ // console.log(modifierIds)
+
+ return (
+ <div className={'w-full flex flex-col gap-0 sticky top-8'}>
+ <Link href="/" passHref>
+ <a
+ className={[
+ 'flex items-center gap-1 text-xs group mb-3',
+ 'text-base transition-all duration-200 text-scale-1100 hover:text-brand-1200 hover:cursor-pointer ',
+ ].join(' ')}
+ >
+ <div className="relative w-2">
+ <div className="transition-all ease-out ml-0 group-hover:-ml-1">
+ <IconChevronLeft size={10} strokeWidth={3} />
+ </div>
+ </div>
+ <span>Back to Main Menu</span>
+ </a>
+ </Link>
+
+ <div className="flex items-center gap-3 my-3">
+ <Image
+ alt={id}
+ width={24}
+ height={24}
+ src={`${router.basePath}/img/icons/menu/${menu.icon}${isDarkMode ? '' : '-light'}.svg`}
+ className="rounded"
+ />
+ <span className={['text-base text-brand-1200 ', !menu.title && 'capitalize'].join(' ')}>
+ {menu.title}
+ </span>
+ <RevVersionDropdown />
+ </div>
+ {/* )} */}
+
+ <ul className="function-link-list">
+ {sections.map((fn: any, fnIndex) => {
+ //
+ // check if the link is allowed to be displayed
+ function isFuncNotInLibraryOrVersion(id, type) {
+ if (id && allowedKeys && !allowedKeys.includes(id) && type !== 'markdown') {
+ /*
+ * Remove this menu link from side bar, as it does not exist for either
+ * this language, or for this lib version
+ *
+ * */
+ return true
+ } else {
+ return false
+ }
+ }
+
+ // run allow check
+ if (isFuncNotInLibraryOrVersion(fn.id, fn.type)) {
+ return <></>
+ }
+
+ const RenderLink = (props) => {
+ const activeAccordianItem = 'using-filters' // useMenuActiveRefId()
+ let active = false
+
+ const isFilter =
+ filterIds && filterIds.length > 0 && filterIds.includes(activeAccordianItem)
+ const isModifier =
+ modifierIds && modifierIds.length > 0 && modifierIds.includes(activeAccordianItem)
+ const isAuthServer =
+ authServerIds &&
+ authServerIds.length > 0 &&
+ authServerIds.includes(activeAccordianItem)
+
+ if (
+ (isFilter && !isModifier && !isAuthServer && props.id === 'using-filters') ||
+ (activeAccordianItem === 'using-filters' && props.id === 'using-filters')
+ ) {
+ active = true
+ } else if (
+ (isModifier && !isFilter && !isAuthServer && props.id === 'using-modifiers') ||
+ (activeAccordianItem === 'using-modifiers' && props.id === 'using-modifiers')
+ ) {
+ active = true
+ } else if (
+ (isAuthServer && !isFilter && !isModifier && props.id === 'admin-api') ||
+ (activeAccordianItem === 'admin-api' && props.id === 'admin-api')
+ ) {
+ active = true
+ } else {
+ active = false
+ }
+
+ return (
+ <Accordion.Root
+ collapsible
+ key={props.id + '-accordian-root-for-func-' + fnIndex}
+ type="single"
+ value={active ? props.id : ''}
+ >
+ <Accordion.Item key={props.id + '-accordian-item'} value={props.id}>
+ <FunctionLink {...props} library={lib} />
+ <Accordion.Content
+ key={props.id + '-sub-items-accordion-container'}
+ className="transition data-open:animate-slide-down data-closed:animate-slide-up ml-2"
+ >
+ {props.items &&
+ props.items
+ .filter((item) => allowedKeys.includes(item.id))
+ .map((item) => {
+ return <FunctionLink {...item} library={lib} />
+ })}
+ </Accordion.Content>
+ </Accordion.Item>
+ </Accordion.Root>
+ )
+ }
+
+ // handle subtitles with subitems
+ if (!fn.id) {
+ return (
+ <>
+ <Divider />
+ <SideMenuTitle title={fn.title} />
+ {fn.items &&
+ fn.items
+ //.filter((item) => item.libs && item.libs.includes(lib))
+ .map((item) => {
+ // run allow check
+ if (isFuncNotInLibraryOrVersion(item.id, item.type)) return <></>
+ return <RenderLink {...item} library={menu.title} />
+ })}
+ </>
+ )
+ } else {
+ // handle normal links
+ return (
+ <>
+ <RenderLink {...fn} library={menu.title} />
+ {fn.items &&
+ fn.items
+ //.filter((item) => item.libs.includes(lib))
+ .map((item) => <RenderLink {...item} library={menu.title} />)}
+ </>
+ )
+ }
+ })}
+ </ul>
+ </div>
+ )
+}
+
+export default React.memo(Content)
diff --git a/apps/docs/layouts/SiteLayout.tsx b/apps/docs/layouts/SiteLayout.tsx
index c6ef90060d3..43caab8c0e9 100644
--- a/apps/docs/layouts/SiteLayout.tsx
+++ b/apps/docs/layouts/SiteLayout.tsx
@@ -7,7 +7,11 @@ import TopNavBarRef from '~/components/Navigation/NavigationMenu/TopNavBarRef'
import FooterHelpCallout from '~/components/FooterHelpCallout'
-import { menuState, useMenuLevelId, useMenuMobileOpen } from '~/hooks/useMenuState'
+import {
+ menuState,
+ // useMenuLevelId,
+ // useMenuMobileOpen
+} from '~/hooks/useMenuState'
import { useEffect } from 'react'
const SiteRefLayout = ({ children }) => {
@@ -23,8 +27,10 @@ const SiteRefLayout = ({ children }) => {
}
}, [])
- const menuLevel = useMenuLevelId()
- const mobileMenuOpen = useMenuMobileOpen()
+ const menuLevel = 'home'
+ // useMenuLevelId()
+ const mobileMenuOpen = false
+ // useMenuMobileOpen()
const levelsData = {
home: {