'use client' import { Feedback } from '~/components/Feedback' import { LegacyGuidesSidebar } from '~/components/GuidesSidebar.legacy' import { VideoPreview } from '~/components/VideoPreview' import { LayoutSwitchButton } from '~/features/DocsLayout/LayoutSwitchButton' import { useDocsLayoutV2 } from '~/features/DocsLayout/useDocsLayoutV2' import { HeadingSlotCrumb } from '~/layouts/HeadingSlot' import { RightRailPortal } from '~/layouts/RightRail' import { useSendTelemetryEvent } from '~/lib/telemetry' import { isFeatureEnabled } from 'common' import { PREFERRED_SOURCE_URL } from 'common/markdown-affordance' import { Google } from 'icons' import { usePathname } from 'next/navigation' import { cn, IconGitHubSolid } from 'ui' import { ExpandableVideo } from 'ui-patterns/ExpandableVideo' import { TocPrimitive, TOCScrollArea } from 'ui-patterns/Toc' import type { TOCItemType } from 'ui-patterns/Toc/server/get-toc' import { toTocTree } from 'ui-patterns/Toc/toc' import { useTocAnchors } from '../features/docs/GuidesMdx.state' interface TOCHeader { id?: string text: string link: string level: number } interface GuidesRightRailProps { video?: string videoTitle?: string hideToc?: boolean editHref?: string } interface GuidesSidebarProps extends GuidesRightRailProps { className?: string } interface GuidePageLinksProps { editHref?: string className?: string } interface GuideTocProps { toc: TOCItemType[] activeUrl: string | undefined } interface GuideTocLinkProps { item: TOCItemType isActive: boolean hasActiveBar?: boolean className?: string } const GuidesSidebar = ({ className, ...props }: GuidesSidebarProps) => useDocsLayoutV2() ? ( ) : ( ) const GuidesRightRail = ({ video, videoTitle, hideToc, editHref }: GuidesRightRailProps) => { const pathname = usePathname() const { toc } = useTocAnchors() const activeIndex = Math.max(TocPrimitive.useTopActiveIndex(toc), 0) const tocVideoPreview = `https://img.youtube.com/vi/${video}/0.jpg` return (
{video ? ( } triggerContainerClassName="rounded-lg focus-ring" /> ) : null} {hideToc || toc.length === 0 ? null : ( )}
) } const GuidePageLinks = ({ editHref, className }: GuidePageLinksProps) => { const pathname = usePathname() const sendTelemetryEvent = useSendTelemetryEvent() const showFeedback = isFeatureEnabled('feedback:docs') const handlePreferredSourceClick = () => sendTelemetryEvent({ action: 'preferred_source_clicked', properties: { pageType: 'guide' } }) return ( ) } const GuideToc = ({ toc, activeUrl }: GuideTocProps) => ( ) const GuideTocLink = ({ item, isActive, hasActiveBar = false, className }: GuideTocLinkProps) => ( {item.title} ) export { GuidePageLinks, GuidesSidebar, GuideToc } export type { TOCHeader }