'use client' import { createContext, useContext, type ReactNode } from 'react' import { cn } from 'ui' import GuidesTableOfContents from '~/components/GuidesSidebar' import { TocAnchorsProvider } from '~/features/docs/GuidesMdx.client' import { type GuideFrontmatter } from '~/lib/docs' interface GuideContextValue { meta?: GuideFrontmatter } const GuideContext = createContext(undefined) export const useGuide = () => { const context = useContext(GuideContext) if (!context) { throw new Error('useGuide must be used within a GuideProvider') } return context } interface GuideProps { meta?: GuideFrontmatter children?: ReactNode className?: string } export function Guide({ meta, children, className }: GuideProps) { const hideToc = meta?.hideToc || meta?.hide_table_of_contents return (
{children}
{!hideToc && ( )}
) }