Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Move API reference to a separate page with its own navbar
0diva5cb185b6589
diff --git a/apps/web/prebuild.js b/apps/web/prebuild.jsindex c9428b9c7..459b9da47 100644--- a/apps/web/prebuild.js+++ b/apps/web/prebuild.js@@ -32,7 +32,7 @@ function buildDirectoryHierarchy(dirPath) {const filesCreated = new Set()function formatModuleTitle(title) {- // Replace underscore with space for _sync and _async suffixes+ // Replace underscore with space for _async and remove sync from name of python-sdk modulesif (title.endsWith('_sync')) {title = title.replace('_sync', '')} else if (title.endsWith('_async')) {diff --git a/apps/web/src/components/Header.tsx b/apps/web/src/components/Header.tsxindex 3fdad9608..982c35325 100644--- a/apps/web/src/components/Header.tsx+++ b/apps/web/src/components/Header.tsx@@ -1,31 +1,43 @@'use client'-import { forwardRef, useEffect } from 'react'-import Link from 'next/link'import clsx from 'clsx'import { motion, useScroll, useTransform } from 'framer-motion'import dynamic from 'next/dynamic'+import Link from 'next/link'import { usePathname } from 'next/navigation'+import { forwardRef, useEffect } from 'react'import { Auth } from '@/components/Auth'+import { GitHubIcon } from '@/components/icons/GitHubIcon'+import { Logo } from '@/components/Logo'import {MobileBurgerMenu,useIsInsideMobileNavigation,useMobileNavigationStore,} from '@/components/MobileBurgerMenu'-import { Logo } from '@/components/Logo'import { useLocalStorage } from 'usehooks-ts'-import { GitHubIcon } from '@/components/icons/GitHubIcon'import { config } from '../../config'-function DocumentationTypeLink({ pathname, href, title }: { pathname: string | null, href: string, title: string }) {+function DocumentationTypeLink({+ pathname,+ href,+ title,+}: {+ pathname: string | null+ href: string+ title: string+}) {if (!pathname) return nullreturn (<LinkclassName={clsx('hover:text-white hover:cursor-pointer text-sm font-medium px-2 py-1 rounded-md',- pathname.startsWith(href) ? 'text-white bg-zinc-800' : 'text-neutral-400'+ pathname.startsWith(href) &&+ // XXX: this is a hack to avoid the /docs and /docs/api-reference links being highlighted at the same time+ !(href === '/docs' && pathname === '/docs/api-reference')+ ? 'text-white bg-zinc-800'+ : 'text-neutral-400')}href={href}>@@ -54,11 +66,10 @@ export const Header = forwardRef(function Header({ className }, ref) {// const isDocs = pathname?.startsWith('/docs')const isAuth = pathname?.startsWith('/auth')-useEffect(() => {fetch(config.github.api)- .then(response => response.json())- .then(data => setGithubStars(data.stargazers_count))+ .then((response) => response.json())+ .then((data) => setGithubStars(data.stargazers_count)).catch(() => setGithubStars(null))}, [setGithubStars])@@ -69,7 +80,7 @@ export const Header = forwardRef(function Header({ className }, ref) {className={clsx(className,'fixed inset-x-0 top-0 z-50 flex h-14 items-center justify-between gap-12 px-4 transition sm:px-6 lg:z-30 lg:px-6',- !isInsideMobileNavigation && 'backdrop-blur-sm dark:backdrop-blur',+ !isInsideMobileNavigation && 'backdrop-blur-sm dark:backdrop-blur')}style={{@@ -82,22 +93,31 @@ export const Header = forwardRef(function Header({ className }, ref) {className={clsx('absolute inset-x-0 top-full h-px transition',(isInsideMobileNavigation || !mobileNavIsOpen) &&- 'bg-zinc-900/7.5 dark:bg-white/7.5',+ 'bg-zinc-900/7.5 dark:bg-white/7.5')}/>{/* Desktop logo */}<div className="relative top-1 hidden items-center justify-start lg:flex gap-4">- <Link- href="/"- aria-label="Home"- >+ <Link href="/" aria-label="Home"><Logo className="h-6" /></Link>- <div className='flex items-center gap-1'>- <DocumentationTypeLink pathname={pathname} href="/docs" title="Documentation" />- {/* <DocumentationTypeLink pathname={pathname} href="/docs/api-reference" title="* Reference" /> */}- <DocumentationTypeLink pathname={pathname} href="/dashboard" title="Dashboard" />+ <div className="flex items-center gap-1">+ <DocumentationTypeLink+ pathname={pathname}+ href="/docs"+ title="Documentation"+ />+ <DocumentationTypeLink+ pathname={pathname}+ href="/docs/api-reference"+ title="API Reference"+ />+ <DocumentationTypeLink+ pathname={pathname}+ href="/dashboard"+ title="Dashboard"+ /></div></div>{/* {isDocs && <Search />} */}@@ -105,26 +125,32 @@ export const Header = forwardRef(function Header({ className }, ref) {{/* Mobile logo + burger menu */}<div className="flex items-center gap-5 lg:hidden"><MobileBurgerMenu />- <Link- href="/"- aria-label="Home"- >+ <Link href="/" aria-label="Home"><Logo className="h-6" /></Link>- <div className='flex items-center gap-1'>- <DocumentationTypeLink pathname={pathname} href="/docs" title="Documentation" />- {/* <DocumentationTypeLink pathname={pathname} href="/docs/api-reference" title="* Reference" /> */}- <DocumentationTypeLink pathname={pathname} href="/dashboard" title="Dashboard" />+ <div className="flex items-center gap-1">+ <DocumentationTypeLink+ pathname={pathname}+ href="/docs"+ title="Documentation"+ />+ <DocumentationTypeLink+ pathname={pathname}+ href="/docs/api-reference"+ title="API Reference"+ />+ <DocumentationTypeLink+ pathname={pathname}+ href="/dashboard"+ title="Dashboard"+ /></div></div>- {!isAuth &&+ {!isAuth && (<div className="flex items-center gap-4"><nav className="hidden md:block">- <ul- role="list"- className="flex items-center gap-4"- >+ <ul role="list" className="flex items-center gap-4"><TopLevelNavItemhref={config.github.url}stat={githubStars}@@ -145,7 +171,7 @@ export const Header = forwardRef(function Header({ className }, ref) {<Auth /></div></div>- }+ )}</motion.div>)})diff --git a/apps/web/src/components/Layout.tsx b/apps/web/src/components/Layout.tsxindex 3bf7af238..c5aa692b4 100644--- a/apps/web/src/components/Layout.tsx+++ b/apps/web/src/components/Layout.tsx@@ -1,11 +1,11 @@'use client'import clsx from 'clsx'-import { usePathname } from 'next/navigation'import { motion } from 'framer-motion'+import { usePathname } from 'next/navigation'import { Footer } from '@/components/Footer'-import { Navigation } from '@/components/Navigation'+import { ApiRefNavigation, DocsNavigation } from '@/components/Navigation'import { Section, SectionProvider } from '@/components/SectionProvider'export function Layout({@@ -18,6 +18,7 @@ export function Layout({const pathname = usePathname()const relativePathname = pathname?.replace(new RegExp('^/docs'), '')const isDocs = pathname?.startsWith('/docs')+ const isApiRef = pathname?.startsWith('/docs/api-reference')const isDashboard = pathname?.startsWith('/dashboard')return (@@ -52,7 +53,7 @@ export function Layout({"><div className="hidden lg:block lg:mt-4">- <Navigation />+ {isApiRef ? <ApiRefNavigation /> : <DocsNavigation />}</div></div>)}diff --git a/apps/web/src/components/MobileBurgerMenu.tsx b/apps/web/src/components/MobileBurgerMenu.tsxindex 54cd987b6..afbbc0f67 100644--- a/apps/web/src/components/MobileBurgerMenu.tsx+++ b/apps/web/src/components/MobileBurgerMenu.tsx@@ -1,13 +1,20 @@'use client'-import { createContext, Fragment, Suspense, useContext, useEffect, useRef } from 'react'-import { usePathname, useSearchParams } from 'next/navigation'import { Dialog, Transition } from '@headlessui/react'import { motion } from 'framer-motion'+import { usePathname, useSearchParams } from 'next/navigation'+import {+ createContext,+ Fragment,+ Suspense,+ useContext,+ useEffect,+ useRef,+} from 'react'import { create } from 'zustand'import { Header } from '@/components/Header'-import { Navigation } from '@/components/Navigation'+import { DocsNavigation } from '@/components/Navigation'function MenuIcon(props: React.ComponentPropsWithoutRef<'svg'>) {return (@@ -66,17 +73,14 @@ function MobileNavigationDialog({if (link &&link.pathname + link.search + link.hash ===- window.location.pathname + window.location.search + window.location.hash+ window.location.pathname + window.location.search + window.location.hash) {close()}}return (- <Transition.Root- show={isOpen}- as={Fragment}- >+ <Transition.Root show={isOpen} as={Fragment}><DialogonClickCapture={onClickDialog}onClose={close}@@ -120,7 +124,7 @@ function MobileNavigationDialog({layoutScrollclassName="fixed bottom-0 left-0 top-14 w-full overflow-y-auto overflow-x-hidden bg-white px-4 pb-4 pt-6 shadow-lg shadow-zinc-900/10 ring-1 ring-zinc-900/7.5 dark:bg-zinc-900 dark:ring-zinc-800 min-[416px]:max-w-sm sm:px-6 sm:pb-10">- <Navigation />+ <DocsNavigation /></motion.div></Transition.Child></Dialog.Panel>@@ -138,11 +142,11 @@ export const useMobileNavigationStore = create<{open: () => voidclose: () => voidtoggle: () => void-}>()(set => ({+}>()((set) => ({isOpen: false,open: () => set({ isOpen: true }),close: () => set({ isOpen: false }),- toggle: () => set(state => ({ isOpen: !state.isOpen })),+ toggle: () => set((state) => ({ isOpen: !state.isOpen })),}))export function MobileBurgerMenu() {@@ -162,10 +166,7 @@ export function MobileBurgerMenu() {</button>{!isInsideMobileNavigation && (<Suspense fallback={null}>- <MobileNavigationDialog- isOpen={isOpen}- close={close}- />+ <MobileNavigationDialog isOpen={isOpen} close={close} /></Suspense>)}</IsInsideMobileNavigationContext.Provider>diff --git a/apps/web/src/components/Navigation/index.tsx b/apps/web/src/components/Navigation/index.tsxindex ed670d2d4..7372188df 100644--- a/apps/web/src/components/Navigation/index.tsx+++ b/apps/web/src/components/Navigation/index.tsx@@ -1,15 +1,21 @@'use client'-import React, { useRef } from 'react'-import { usePathname } from 'next/navigation'import clsx from 'clsx'import { motion } from 'framer-motion'+import { usePathname } from 'next/navigation'+import React, { useRef } from 'react'import { useIsInsideMobileNavigation } from '@/components/MobileBurgerMenu'import { useSectionStore } from '@/components/SectionProvider'-import { routes, NavGroup, NavSubgroup, NavLink } from './routes'-import { NavigationSubgroup } from './NavigationSubgroup'import { NavigationLink } from './NavigationLink'+import { NavigationSubgroup } from './NavigationSubgroup'+import {+ NavGroup,+ NavLink,+ NavSubgroup,+ apiRefRoutes,+ docRoutes,+} from './routes'function useInitialValue<T>(value: T, condition = true) {const initialValue = useRef(value).current@@ -74,16 +80,33 @@ function NavigationGroup({)}-export function Navigation(props) {+export function DocsNavigation(props) {+ return (+ <nav {...props}>+ <ul role="list">+ {docRoutes.map((group, groupIndex) => (+ <NavigationGroup+ key={groupIndex}+ group={group}+ className={groupIndex === 0 ? 'md:mt-0' : undefined}+ isLast={groupIndex === docRoutes.length - 1}+ />+ ))}+ </ul>+ </nav>+ )+}++export function ApiRefNavigation(props) {return (<nav {...props}><ul role="list">- {routes.map((group, groupIndex) => (+ {apiRefRoutes.map((group, groupIndex) => (<NavigationGroupkey={groupIndex}group={group}className={groupIndex === 0 ? 'md:mt-0' : undefined}- isLast={groupIndex === routes.length - 1}+ isLast={groupIndex === docRoutes.length - 1}/>))}</ul>diff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsxindex 7b7cc0254..57bca3213 100644--- a/apps/web/src/components/Navigation/routes.tsx+++ b/apps/web/src/components/Navigation/routes.tsx@@ -1,5 +1,5 @@import { Braces, CheckCircle, Home, MessagesSquare } from 'lucide-react'-import apiRefRoutes from './apiRefRoutes.json'+import apiRefRoutesJson from './apiRefRoutes.json'export interface NavLink {title: string@@ -19,7 +19,7 @@ export interface NavGroup {items: Array<NavLink | NavSubgroup>}-export const routes: NavGroup[] = [+export const docRoutes: NavGroup[] = [{items: [{@@ -441,5 +441,6 @@ export const routes: NavGroup[] = [// },// ]// },- ...apiRefRoutes,]++export const apiRefRoutes: NavGroup[] = apiRefRoutesJson