diff --git a/next.config.ts b/next.config.ts index 3b1c083..fd8137d 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,5 @@ import type { NextConfig } from 'next' import createMDX from '@next/mdx' -import rehypeSlug from 'rehype-slug' const nextConfig: NextConfig = { /* config options here */ @@ -10,7 +9,7 @@ const nextConfig: NextConfig = { const withMDX = createMDX({ extension : /\.mdx?$/, options: { - rehypePlugins: [rehypeSlug], + rehypePlugins: [['rehype-slug', {}]], }, }) diff --git a/src/components/docs-footer.tsx b/src/components/docs-footer.tsx new file mode 100644 index 0000000..541a219 --- /dev/null +++ b/src/components/docs-footer.tsx @@ -0,0 +1,115 @@ +'use client' + +import * as React from 'react' +import Link from 'next/link' +import { usePathname } from 'next/navigation' +import { ThumbsUp, ThumbsDown, Github, ChevronLeft, ChevronRight } from 'lucide-react' +import { docsConfig, type NavItemWithChildren, type NavItem } from '@/config/docs' +import { cn } from '@/lib/utils' +import { Button } from '@/components/ui/button' + +export function DocsFooter() { + const pathname = usePathname() + const [feedback, setFeedback] = React.useState<'yes' | 'no' | null>(null) + + // Flatten the sidebarNav to get a sequential list of links + const flattenedLinks = React.useMemo(() => { + const links: NavItem[] = [] + + // We only care about sidebarNav because it dictates the reading flow + const flatten = (items: NavItemWithChildren[]) => { + for (const item of items) { + if (item.href) { + links.push(item) + } + if (item.items && item.items.length > 0) { + flatten(item.items) + } + } + } + + flatten(docsConfig.sidebarNav) + return links + }, []) + + // Find current index + const currentIndex = flattenedLinks.findIndex((link) => link.href === pathname) + const prevLink = currentIndex > 0 ? flattenedLinks[currentIndex - 1] : null + const nextLink = currentIndex >= 0 && currentIndex < flattenedLinks.length - 1 ? flattenedLinks[currentIndex + 1] : null + + return ( + + ) +} diff --git a/src/components/docs-layout.tsx b/src/components/docs-layout.tsx index 0b9324e..8c38231 100644 --- a/src/components/docs-layout.tsx +++ b/src/components/docs-layout.tsx @@ -3,6 +3,7 @@ import { DocsSidebar } from '@/components/docs-sidebar' import { SiteHeader } from '@/components/site-header' import { TableOfContents } from '@/components/toc' +import { DocsFooter } from '@/components/docs-footer' interface DocsLayoutProps { children: React.ReactNode @@ -16,7 +17,10 @@ export function DocsLayout({ children }: DocsLayoutProps) {