docs-sidebar.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. "use client";
  2. import Link from "next/link";
  3. import { usePathname } from "next/navigation";
  4. import { cn } from "@/lib/utils";
  5. const navigation = [
  6. {
  7. title: "Getting Started",
  8. items: [
  9. { title: "Introduction", href: "/docs" },
  10. { title: "Installation", href: "/docs/installation" },
  11. { title: "Quick Start", href: "/docs/quick-start" },
  12. { title: "Changelog", href: "/docs/changelog" },
  13. ],
  14. },
  15. {
  16. title: "Core Concepts",
  17. items: [
  18. { title: "Specs", href: "/docs/specs" },
  19. { title: "Schemas", href: "/docs/schemas" },
  20. { title: "Catalog", href: "/docs/catalog" },
  21. { title: "Registry", href: "/docs/registry" },
  22. { title: "Data Binding", href: "/docs/data-binding" },
  23. { title: "Visibility", href: "/docs/visibility" },
  24. { title: "Validation", href: "/docs/validation" },
  25. ],
  26. },
  27. {
  28. title: "Examples",
  29. items: [
  30. {
  31. title: "Dashboard",
  32. href: "https://github.com/vercel-labs/json-render/tree/main/examples/dashboard",
  33. external: true,
  34. },
  35. {
  36. title: "Remotion",
  37. href: "https://github.com/vercel-labs/json-render/tree/main/examples/remotion",
  38. external: true,
  39. },
  40. ],
  41. },
  42. {
  43. title: "Guides",
  44. items: [
  45. { title: "Custom Schema", href: "/docs/custom-schema" },
  46. { title: "Streaming", href: "/docs/streaming" },
  47. { title: "Code Export", href: "/docs/code-export" },
  48. ],
  49. },
  50. {
  51. title: "Integrations",
  52. items: [
  53. { title: "AI SDK", href: "/docs/ai-sdk" },
  54. { title: "A2UI", href: "/docs/a2ui" },
  55. { title: "Adaptive Cards", href: "/docs/adaptive-cards" },
  56. { title: "AG-UI", href: "/docs/ag-ui" },
  57. { title: "OpenAPI", href: "/docs/openapi" },
  58. ],
  59. },
  60. {
  61. title: "API Reference",
  62. items: [
  63. { title: "@json-render/core", href: "/docs/api/core" },
  64. { title: "@json-render/react", href: "/docs/api/react" },
  65. { title: "@json-render/remotion", href: "/docs/api/remotion" },
  66. { title: "@json-render/codegen", href: "/docs/api/codegen" },
  67. ],
  68. },
  69. ];
  70. export function DocsSidebar() {
  71. const pathname = usePathname();
  72. return (
  73. <nav className="space-y-6 pb-8">
  74. {navigation.map((section) => (
  75. <div key={section.title}>
  76. <h4 className="text-xs font-normal text-muted-foreground/50 uppercase tracking-wider mb-2">
  77. {section.title}
  78. </h4>
  79. <ul className="space-y-1">
  80. {section.items.map((item) => {
  81. const isActive = pathname === item.href;
  82. const isExternal = "external" in item && item.external;
  83. return (
  84. <li key={item.href}>
  85. <Link
  86. href={item.href}
  87. {...(isExternal && {
  88. target: "_blank",
  89. rel: "noopener noreferrer",
  90. })}
  91. className={cn(
  92. "text-sm transition-colors block py-1",
  93. isActive
  94. ? "text-primary font-medium"
  95. : "text-muted-foreground hover:text-foreground",
  96. isExternal && "inline-flex items-center gap-1",
  97. )}
  98. >
  99. {item.title}
  100. {isExternal && (
  101. <svg
  102. className="w-3 h-3"
  103. fill="none"
  104. stroke="currentColor"
  105. viewBox="0 0 24 24"
  106. >
  107. <path
  108. strokeLinecap="round"
  109. strokeLinejoin="round"
  110. strokeWidth={2}
  111. d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
  112. />
  113. </svg>
  114. )}
  115. </Link>
  116. </li>
  117. );
  118. })}
  119. </ul>
  120. </div>
  121. ))}
  122. </nav>
  123. );
  124. }