@brainfish-ai/devdoc 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +33 -0
- package/README.md +415 -0
- package/bin/devdoc.js +13 -0
- package/dist/cli/commands/build.d.ts +5 -0
- package/dist/cli/commands/build.js +87 -0
- package/dist/cli/commands/check.d.ts +1 -0
- package/dist/cli/commands/check.js +143 -0
- package/dist/cli/commands/create.d.ts +24 -0
- package/dist/cli/commands/create.js +387 -0
- package/dist/cli/commands/deploy.d.ts +9 -0
- package/dist/cli/commands/deploy.js +433 -0
- package/dist/cli/commands/dev.d.ts +6 -0
- package/dist/cli/commands/dev.js +139 -0
- package/dist/cli/commands/init.d.ts +11 -0
- package/dist/cli/commands/init.js +238 -0
- package/dist/cli/commands/keys.d.ts +12 -0
- package/dist/cli/commands/keys.js +165 -0
- package/dist/cli/commands/start.d.ts +5 -0
- package/dist/cli/commands/start.js +56 -0
- package/dist/cli/commands/upload.d.ts +13 -0
- package/dist/cli/commands/upload.js +238 -0
- package/dist/cli/commands/whoami.d.ts +8 -0
- package/dist/cli/commands/whoami.js +91 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +106 -0
- package/dist/config/index.d.ts +80 -0
- package/dist/config/index.js +133 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.js +13 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +12 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.js +61 -0
- package/dist/utils/paths.d.ts +16 -0
- package/dist/utils/paths.js +50 -0
- package/package.json +51 -0
- package/renderer/app/api/assets/[...path]/route.ts +123 -0
- package/renderer/app/api/assets/route.ts +124 -0
- package/renderer/app/api/assets/upload/route.ts +177 -0
- package/renderer/app/api/auth-schemes/route.ts +77 -0
- package/renderer/app/api/chat/route.ts +858 -0
- package/renderer/app/api/codegen/route.ts +72 -0
- package/renderer/app/api/collections/route.ts +1016 -0
- package/renderer/app/api/debug/route.ts +53 -0
- package/renderer/app/api/deploy/route.ts +234 -0
- package/renderer/app/api/device/route.ts +42 -0
- package/renderer/app/api/docs/route.ts +187 -0
- package/renderer/app/api/keys/regenerate/route.ts +80 -0
- package/renderer/app/api/openapi-spec/route.ts +151 -0
- package/renderer/app/api/projects/[slug]/route.ts +153 -0
- package/renderer/app/api/projects/[slug]/stats/route.ts +96 -0
- package/renderer/app/api/projects/register/route.ts +152 -0
- package/renderer/app/api/proxy/route.ts +149 -0
- package/renderer/app/api/proxy-stream/route.ts +168 -0
- package/renderer/app/api/redirects/route.ts +47 -0
- package/renderer/app/api/schema/route.ts +65 -0
- package/renderer/app/api/subdomains/check/route.ts +172 -0
- package/renderer/app/api/suggestions/route.ts +144 -0
- package/renderer/app/favicon.ico +0 -0
- package/renderer/app/globals.css +1103 -0
- package/renderer/app/layout.tsx +47 -0
- package/renderer/app/llms-full.txt/route.ts +346 -0
- package/renderer/app/llms.txt/route.ts +279 -0
- package/renderer/app/page.tsx +14 -0
- package/renderer/app/robots.txt/route.ts +84 -0
- package/renderer/app/sitemap.xml/route.ts +199 -0
- package/renderer/components/docs/index.ts +12 -0
- package/renderer/components/docs/mdx/accordion.tsx +169 -0
- package/renderer/components/docs/mdx/badge.tsx +132 -0
- package/renderer/components/docs/mdx/callouts.tsx +154 -0
- package/renderer/components/docs/mdx/cards.tsx +213 -0
- package/renderer/components/docs/mdx/changelog.tsx +120 -0
- package/renderer/components/docs/mdx/code-block.tsx +186 -0
- package/renderer/components/docs/mdx/code-group.tsx +421 -0
- package/renderer/components/docs/mdx/file-embeds.tsx +105 -0
- package/renderer/components/docs/mdx/frame.tsx +112 -0
- package/renderer/components/docs/mdx/highlight.tsx +151 -0
- package/renderer/components/docs/mdx/iframe.tsx +134 -0
- package/renderer/components/docs/mdx/image.tsx +235 -0
- package/renderer/components/docs/mdx/index.ts +204 -0
- package/renderer/components/docs/mdx/mermaid.tsx +240 -0
- package/renderer/components/docs/mdx/param-field.tsx +200 -0
- package/renderer/components/docs/mdx/steps.tsx +113 -0
- package/renderer/components/docs/mdx/tabs.tsx +86 -0
- package/renderer/components/docs/mdx-renderer.tsx +100 -0
- package/renderer/components/docs/navigation/breadcrumbs.tsx +76 -0
- package/renderer/components/docs/navigation/index.ts +8 -0
- package/renderer/components/docs/navigation/page-nav.tsx +64 -0
- package/renderer/components/docs/navigation/sidebar.tsx +515 -0
- package/renderer/components/docs/navigation/toc.tsx +113 -0
- package/renderer/components/docs/notice.tsx +105 -0
- package/renderer/components/docs-header.tsx +274 -0
- package/renderer/components/docs-viewer/agent/agent-chat.tsx +2076 -0
- package/renderer/components/docs-viewer/agent/cards/debug-context-card.tsx +90 -0
- package/renderer/components/docs-viewer/agent/cards/endpoint-context-card.tsx +49 -0
- package/renderer/components/docs-viewer/agent/cards/index.tsx +50 -0
- package/renderer/components/docs-viewer/agent/cards/response-options-card.tsx +212 -0
- package/renderer/components/docs-viewer/agent/cards/types.ts +84 -0
- package/renderer/components/docs-viewer/agent/chat-message.tsx +17 -0
- package/renderer/components/docs-viewer/agent/index.tsx +6 -0
- package/renderer/components/docs-viewer/agent/messages/assistant-message.tsx +119 -0
- package/renderer/components/docs-viewer/agent/messages/chat-message.tsx +46 -0
- package/renderer/components/docs-viewer/agent/messages/index.ts +17 -0
- package/renderer/components/docs-viewer/agent/messages/tool-call-display.tsx +721 -0
- package/renderer/components/docs-viewer/agent/messages/types.ts +61 -0
- package/renderer/components/docs-viewer/agent/messages/typing-indicator.tsx +24 -0
- package/renderer/components/docs-viewer/agent/messages/user-message.tsx +51 -0
- package/renderer/components/docs-viewer/code-editor/index.tsx +2 -0
- package/renderer/components/docs-viewer/code-editor/notes-mode.tsx +1283 -0
- package/renderer/components/docs-viewer/content/changelog-page.tsx +331 -0
- package/renderer/components/docs-viewer/content/doc-page.tsx +285 -0
- package/renderer/components/docs-viewer/content/documentation-viewer.tsx +17 -0
- package/renderer/components/docs-viewer/content/index.tsx +29 -0
- package/renderer/components/docs-viewer/content/introduction.tsx +21 -0
- package/renderer/components/docs-viewer/content/request-details.tsx +330 -0
- package/renderer/components/docs-viewer/content/sections/auth.tsx +69 -0
- package/renderer/components/docs-viewer/content/sections/body.tsx +66 -0
- package/renderer/components/docs-viewer/content/sections/headers.tsx +43 -0
- package/renderer/components/docs-viewer/content/sections/overview.tsx +40 -0
- package/renderer/components/docs-viewer/content/sections/parameters.tsx +43 -0
- package/renderer/components/docs-viewer/content/sections/responses.tsx +87 -0
- package/renderer/components/docs-viewer/global-auth-modal.tsx +352 -0
- package/renderer/components/docs-viewer/index.tsx +1466 -0
- package/renderer/components/docs-viewer/playground/auth-editor.tsx +280 -0
- package/renderer/components/docs-viewer/playground/body-editor.tsx +221 -0
- package/renderer/components/docs-viewer/playground/code-editor.tsx +224 -0
- package/renderer/components/docs-viewer/playground/code-snippet.tsx +387 -0
- package/renderer/components/docs-viewer/playground/graphql-playground.tsx +745 -0
- package/renderer/components/docs-viewer/playground/index.tsx +671 -0
- package/renderer/components/docs-viewer/playground/key-value-editor.tsx +261 -0
- package/renderer/components/docs-viewer/playground/method-selector.tsx +60 -0
- package/renderer/components/docs-viewer/playground/request-builder.tsx +179 -0
- package/renderer/components/docs-viewer/playground/request-tabs.tsx +237 -0
- package/renderer/components/docs-viewer/playground/response-cards/idle-card.tsx +21 -0
- package/renderer/components/docs-viewer/playground/response-cards/index.tsx +93 -0
- package/renderer/components/docs-viewer/playground/response-cards/loading-card.tsx +16 -0
- package/renderer/components/docs-viewer/playground/response-cards/network-error-card.tsx +23 -0
- package/renderer/components/docs-viewer/playground/response-cards/response-body-card.tsx +268 -0
- package/renderer/components/docs-viewer/playground/response-cards/types.ts +82 -0
- package/renderer/components/docs-viewer/playground/response-viewer.tsx +43 -0
- package/renderer/components/docs-viewer/search/index.ts +2 -0
- package/renderer/components/docs-viewer/search/search-dialog.tsx +331 -0
- package/renderer/components/docs-viewer/search/use-search.ts +117 -0
- package/renderer/components/docs-viewer/shared/markdown-renderer.tsx +431 -0
- package/renderer/components/docs-viewer/shared/method-badge.tsx +41 -0
- package/renderer/components/docs-viewer/shared/schema-viewer.tsx +349 -0
- package/renderer/components/docs-viewer/sidebar/collection-tree.tsx +239 -0
- package/renderer/components/docs-viewer/sidebar/endpoint-options.tsx +316 -0
- package/renderer/components/docs-viewer/sidebar/index.tsx +343 -0
- package/renderer/components/docs-viewer/sidebar/right-sidebar.tsx +202 -0
- package/renderer/components/docs-viewer/sidebar/sidebar-group.tsx +118 -0
- package/renderer/components/docs-viewer/sidebar/sidebar-item.tsx +226 -0
- package/renderer/components/docs-viewer/sidebar/sidebar-section.tsx +52 -0
- package/renderer/components/theme-provider.tsx +11 -0
- package/renderer/components/theme-toggle.tsx +76 -0
- package/renderer/components/ui/badge.tsx +46 -0
- package/renderer/components/ui/button.tsx +59 -0
- package/renderer/components/ui/dialog.tsx +118 -0
- package/renderer/components/ui/dropdown-menu.tsx +257 -0
- package/renderer/components/ui/input.tsx +21 -0
- package/renderer/components/ui/label.tsx +24 -0
- package/renderer/components/ui/navigation-menu.tsx +168 -0
- package/renderer/components/ui/select.tsx +190 -0
- package/renderer/components/ui/spinner.tsx +114 -0
- package/renderer/components/ui/tabs.tsx +66 -0
- package/renderer/components/ui/tooltip.tsx +61 -0
- package/renderer/hooks/use-code-copy.ts +88 -0
- package/renderer/hooks/use-openapi-title.ts +44 -0
- package/renderer/lib/api-docs/agent/index.ts +6 -0
- package/renderer/lib/api-docs/agent/indexer.ts +323 -0
- package/renderer/lib/api-docs/agent/spec-summary.ts +335 -0
- package/renderer/lib/api-docs/agent/types.ts +116 -0
- package/renderer/lib/api-docs/auth/auth-context.tsx +225 -0
- package/renderer/lib/api-docs/auth/auth-storage.ts +87 -0
- package/renderer/lib/api-docs/auth/crypto.ts +89 -0
- package/renderer/lib/api-docs/auth/index.ts +4 -0
- package/renderer/lib/api-docs/code-editor/db.ts +164 -0
- package/renderer/lib/api-docs/code-editor/hooks.ts +266 -0
- package/renderer/lib/api-docs/code-editor/index.ts +6 -0
- package/renderer/lib/api-docs/code-editor/mode-context.tsx +207 -0
- package/renderer/lib/api-docs/code-editor/types.ts +105 -0
- package/renderer/lib/api-docs/codegen/definitions.ts +297 -0
- package/renderer/lib/api-docs/codegen/har.ts +251 -0
- package/renderer/lib/api-docs/codegen/index.ts +159 -0
- package/renderer/lib/api-docs/factories.ts +151 -0
- package/renderer/lib/api-docs/index.ts +17 -0
- package/renderer/lib/api-docs/mobile-context.tsx +112 -0
- package/renderer/lib/api-docs/navigation-context.tsx +88 -0
- package/renderer/lib/api-docs/parsers/graphql/README.md +129 -0
- package/renderer/lib/api-docs/parsers/graphql/index.ts +91 -0
- package/renderer/lib/api-docs/parsers/graphql/parser.ts +491 -0
- package/renderer/lib/api-docs/parsers/graphql/transformer.ts +246 -0
- package/renderer/lib/api-docs/parsers/graphql/types.ts +283 -0
- package/renderer/lib/api-docs/parsers/openapi/README.md +32 -0
- package/renderer/lib/api-docs/parsers/openapi/dereferencer.ts +60 -0
- package/renderer/lib/api-docs/parsers/openapi/extractors/auth.ts +574 -0
- package/renderer/lib/api-docs/parsers/openapi/extractors/body.ts +403 -0
- package/renderer/lib/api-docs/parsers/openapi/extractors/index.ts +232 -0
- package/renderer/lib/api-docs/parsers/openapi/index.ts +171 -0
- package/renderer/lib/api-docs/parsers/openapi/transformer.ts +277 -0
- package/renderer/lib/api-docs/parsers/openapi/validator.ts +31 -0
- package/renderer/lib/api-docs/playground/context.tsx +107 -0
- package/renderer/lib/api-docs/playground/navigation-context.tsx +124 -0
- package/renderer/lib/api-docs/playground/request-builder.ts +223 -0
- package/renderer/lib/api-docs/playground/request-runner.ts +282 -0
- package/renderer/lib/api-docs/playground/types.ts +35 -0
- package/renderer/lib/api-docs/types.ts +269 -0
- package/renderer/lib/api-docs/utils.ts +311 -0
- package/renderer/lib/cache.ts +193 -0
- package/renderer/lib/docs/config/index.ts +29 -0
- package/renderer/lib/docs/config/loader.ts +142 -0
- package/renderer/lib/docs/config/schema.ts +298 -0
- package/renderer/lib/docs/index.ts +12 -0
- package/renderer/lib/docs/mdx/compiler.ts +176 -0
- package/renderer/lib/docs/mdx/frontmatter.ts +80 -0
- package/renderer/lib/docs/mdx/index.ts +26 -0
- package/renderer/lib/docs/navigation/generator.ts +348 -0
- package/renderer/lib/docs/navigation/index.ts +12 -0
- package/renderer/lib/docs/navigation/types.ts +123 -0
- package/renderer/lib/docs-navigation-context.tsx +80 -0
- package/renderer/lib/multi-tenant/context.ts +105 -0
- package/renderer/lib/storage/blob.ts +845 -0
- package/renderer/lib/utils.ts +6 -0
- package/renderer/next.config.ts +76 -0
- package/renderer/package.json +66 -0
- package/renderer/postcss.config.mjs +5 -0
- package/renderer/public/assets/images/screenshot.png +0 -0
- package/renderer/public/assets/logo/dark.svg +9 -0
- package/renderer/public/assets/logo/light.svg +9 -0
- package/renderer/public/assets/logo.svg +9 -0
- package/renderer/public/file.svg +1 -0
- package/renderer/public/globe.svg +1 -0
- package/renderer/public/icon.png +0 -0
- package/renderer/public/logo.svg +9 -0
- package/renderer/public/window.svg +1 -0
- package/renderer/tsconfig.json +28 -0
- package/templates/basic/README.md +139 -0
- package/templates/basic/assets/favicon.svg +4 -0
- package/templates/basic/assets/logo.svg +9 -0
- package/templates/basic/docs.json +47 -0
- package/templates/basic/guides/configuration.mdx +149 -0
- package/templates/basic/guides/overview.mdx +96 -0
- package/templates/basic/index.mdx +39 -0
- package/templates/basic/package.json +14 -0
- package/templates/basic/quickstart.mdx +92 -0
- package/templates/basic/vercel.json +6 -0
- package/templates/graphql/README.md +139 -0
- package/templates/graphql/api-reference/schema.graphql +305 -0
- package/templates/graphql/assets/favicon.svg +4 -0
- package/templates/graphql/assets/logo.svg +9 -0
- package/templates/graphql/docs.json +54 -0
- package/templates/graphql/guides/configuration.mdx +149 -0
- package/templates/graphql/guides/overview.mdx +96 -0
- package/templates/graphql/index.mdx +39 -0
- package/templates/graphql/package.json +14 -0
- package/templates/graphql/quickstart.mdx +92 -0
- package/templates/graphql/vercel.json +6 -0
- package/templates/openapi/README.md +139 -0
- package/templates/openapi/api-reference/openapi.json +419 -0
- package/templates/openapi/assets/favicon.svg +4 -0
- package/templates/openapi/assets/logo.svg +9 -0
- package/templates/openapi/docs.json +61 -0
- package/templates/openapi/guides/configuration.mdx +149 -0
- package/templates/openapi/guides/overview.mdx +96 -0
- package/templates/openapi/index.mdx +39 -0
- package/templates/openapi/package.json +14 -0
- package/templates/openapi/quickstart.mdx +92 -0
- package/templates/openapi/vercel.json +6 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { cn } from '@/lib/utils'
|
|
5
|
+
import {
|
|
6
|
+
Info as InfoIcon,
|
|
7
|
+
Warning as WarningIcon,
|
|
8
|
+
Lightbulb,
|
|
9
|
+
Note as NoteIcon,
|
|
10
|
+
CheckCircle,
|
|
11
|
+
XCircle,
|
|
12
|
+
} from '@phosphor-icons/react'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Callout Components for MDX Documentation
|
|
16
|
+
*
|
|
17
|
+
* Mintlify-compatible callout components for highlighting important information.
|
|
18
|
+
* Supports: Note, Warning, Info, Tip, Check, Error
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
interface CalloutProps {
|
|
22
|
+
children: React.ReactNode
|
|
23
|
+
title?: string
|
|
24
|
+
className?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type CalloutVariant = 'note' | 'warning' | 'info' | 'tip' | 'check' | 'error'
|
|
28
|
+
|
|
29
|
+
const calloutConfig: Record<
|
|
30
|
+
CalloutVariant,
|
|
31
|
+
{
|
|
32
|
+
icon: React.ComponentType<{ className?: string; weight?: 'fill' | 'regular' }>
|
|
33
|
+
defaultTitle: string
|
|
34
|
+
containerClass: string
|
|
35
|
+
iconClass: string
|
|
36
|
+
titleClass: string
|
|
37
|
+
}
|
|
38
|
+
> = {
|
|
39
|
+
note: {
|
|
40
|
+
icon: NoteIcon,
|
|
41
|
+
defaultTitle: 'Note',
|
|
42
|
+
containerClass: 'border-blue-500/30 bg-blue-500/10 dark:border-blue-400/30 dark:bg-blue-400/10',
|
|
43
|
+
iconClass: 'text-blue-600 dark:text-blue-400',
|
|
44
|
+
titleClass: 'text-blue-700 dark:text-blue-300',
|
|
45
|
+
},
|
|
46
|
+
warning: {
|
|
47
|
+
icon: WarningIcon,
|
|
48
|
+
defaultTitle: 'Warning',
|
|
49
|
+
containerClass: 'border-amber-500/30 bg-amber-500/10 dark:border-amber-400/30 dark:bg-amber-400/10',
|
|
50
|
+
iconClass: 'text-amber-600 dark:text-amber-400',
|
|
51
|
+
titleClass: 'text-amber-700 dark:text-amber-300',
|
|
52
|
+
},
|
|
53
|
+
info: {
|
|
54
|
+
icon: InfoIcon,
|
|
55
|
+
defaultTitle: 'Info',
|
|
56
|
+
containerClass: 'border-sky-500/30 bg-sky-500/10 dark:border-sky-400/30 dark:bg-sky-400/10',
|
|
57
|
+
iconClass: 'text-sky-600 dark:text-sky-400',
|
|
58
|
+
titleClass: 'text-sky-700 dark:text-sky-300',
|
|
59
|
+
},
|
|
60
|
+
tip: {
|
|
61
|
+
icon: Lightbulb,
|
|
62
|
+
defaultTitle: 'Tip',
|
|
63
|
+
containerClass: 'border-emerald-500/30 bg-emerald-500/10 dark:border-emerald-400/30 dark:bg-emerald-400/10',
|
|
64
|
+
iconClass: 'text-emerald-600 dark:text-emerald-400',
|
|
65
|
+
titleClass: 'text-emerald-700 dark:text-emerald-300',
|
|
66
|
+
},
|
|
67
|
+
check: {
|
|
68
|
+
icon: CheckCircle,
|
|
69
|
+
defaultTitle: 'Success',
|
|
70
|
+
containerClass: 'border-green-500/30 bg-green-500/10 dark:border-green-400/30 dark:bg-green-400/10',
|
|
71
|
+
iconClass: 'text-green-600 dark:text-green-400',
|
|
72
|
+
titleClass: 'text-green-700 dark:text-green-300',
|
|
73
|
+
},
|
|
74
|
+
error: {
|
|
75
|
+
icon: XCircle,
|
|
76
|
+
defaultTitle: 'Error',
|
|
77
|
+
containerClass: 'border-red-500/30 bg-red-500/10 dark:border-red-400/30 dark:bg-red-400/10',
|
|
78
|
+
iconClass: 'text-red-600 dark:text-red-400',
|
|
79
|
+
titleClass: 'text-red-700 dark:text-red-300',
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function BaseCallout({
|
|
84
|
+
variant,
|
|
85
|
+
children,
|
|
86
|
+
title,
|
|
87
|
+
className,
|
|
88
|
+
}: CalloutProps & { variant: CalloutVariant }) {
|
|
89
|
+
const config = calloutConfig[variant]
|
|
90
|
+
const Icon = config.icon
|
|
91
|
+
const displayTitle = title ?? config.defaultTitle
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div
|
|
95
|
+
className={cn(
|
|
96
|
+
`docs-callout docs-callout-${variant} my-4 rounded-lg border p-4`,
|
|
97
|
+
config.containerClass,
|
|
98
|
+
className
|
|
99
|
+
)}
|
|
100
|
+
>
|
|
101
|
+
<div className="flex items-start gap-3">
|
|
102
|
+
<Icon
|
|
103
|
+
className={cn('docs-callout-icon mt-0.5 h-5 w-5 shrink-0', config.iconClass)}
|
|
104
|
+
weight="fill"
|
|
105
|
+
/>
|
|
106
|
+
<div className="docs-callout-content flex-1 min-w-0">
|
|
107
|
+
{displayTitle && (
|
|
108
|
+
<div className={cn('docs-callout-title font-semibold text-sm mb-1', config.titleClass)}>
|
|
109
|
+
{displayTitle}
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
<div className="docs-callout-body text-sm text-foreground/90 [&>p]:mb-2 [&>p:last-child]:mb-0 [&>ul]:mt-2 [&>ol]:mt-2">
|
|
113
|
+
{children}
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Individual callout components for MDX usage
|
|
122
|
+
export function Note({ children, title, className }: CalloutProps) {
|
|
123
|
+
return <BaseCallout variant="note" title={title} className={className}>{children}</BaseCallout>
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function Warning({ children, title, className }: CalloutProps) {
|
|
127
|
+
return <BaseCallout variant="warning" title={title} className={className}>{children}</BaseCallout>
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function Info({ children, title, className }: CalloutProps) {
|
|
131
|
+
return <BaseCallout variant="info" title={title} className={className}>{children}</BaseCallout>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function Tip({ children, title, className }: CalloutProps) {
|
|
135
|
+
return <BaseCallout variant="tip" title={title} className={className}>{children}</BaseCallout>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function Check({ children, title, className }: CalloutProps) {
|
|
139
|
+
return <BaseCallout variant="check" title={title} className={className}>{children}</BaseCallout>
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function Error({ children, title, className }: CalloutProps) {
|
|
143
|
+
return <BaseCallout variant="error" title={title} className={className}>{children}</BaseCallout>
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Generic Callout component with type prop
|
|
147
|
+
export function Callout({
|
|
148
|
+
type = 'note',
|
|
149
|
+
children,
|
|
150
|
+
title,
|
|
151
|
+
className
|
|
152
|
+
}: CalloutProps & { type?: CalloutVariant }) {
|
|
153
|
+
return <BaseCallout variant={type} title={title} className={className}>{children}</BaseCallout>
|
|
154
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import Link from 'next/link'
|
|
5
|
+
import { cn } from '@/lib/utils'
|
|
6
|
+
import { ArrowRight, ArrowSquareOut } from '@phosphor-icons/react'
|
|
7
|
+
import * as PhosphorIcons from '@phosphor-icons/react'
|
|
8
|
+
import { useDocsNavigation } from '@/lib/docs-navigation-context'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Card Components for MDX Documentation
|
|
12
|
+
*
|
|
13
|
+
* Mintlify-compatible card components for navigation and content organization.
|
|
14
|
+
* Supports both ApiDocs hash-based navigation and standalone /docs route navigation.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface CardProps {
|
|
18
|
+
title: string
|
|
19
|
+
children?: React.ReactNode
|
|
20
|
+
icon?: string
|
|
21
|
+
href?: string
|
|
22
|
+
horizontal?: boolean
|
|
23
|
+
img?: string
|
|
24
|
+
cta?: string
|
|
25
|
+
arrow?: boolean
|
|
26
|
+
className?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Dynamic icon resolver for Phosphor icons
|
|
30
|
+
function getIcon(iconName: string): React.ComponentType<{ className?: string; weight?: string }> | null {
|
|
31
|
+
if (!iconName) return null
|
|
32
|
+
|
|
33
|
+
// Convert kebab-case or snake_case to PascalCase
|
|
34
|
+
const pascalCase = iconName
|
|
35
|
+
.split(/[-_]/)
|
|
36
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
37
|
+
.join('')
|
|
38
|
+
|
|
39
|
+
// Try to get the icon from Phosphor
|
|
40
|
+
const Icon = (PhosphorIcons as Record<string, unknown>)[pascalCase] as React.ComponentType<{ className?: string; weight?: string }> | undefined
|
|
41
|
+
return Icon || null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function Card({
|
|
45
|
+
title,
|
|
46
|
+
children,
|
|
47
|
+
icon,
|
|
48
|
+
href,
|
|
49
|
+
horizontal = false,
|
|
50
|
+
img,
|
|
51
|
+
cta,
|
|
52
|
+
arrow,
|
|
53
|
+
className,
|
|
54
|
+
}: CardProps) {
|
|
55
|
+
const Icon = icon ? getIcon(icon) : null
|
|
56
|
+
const isExternal = href?.startsWith('http') || href?.startsWith('//')
|
|
57
|
+
const docsNav = useDocsNavigation()
|
|
58
|
+
|
|
59
|
+
// Check if this is a tab switch link (/api-reference, /changelog)
|
|
60
|
+
const isTabSwitchLink = (href === '/api-reference' || href === '/changelog') && docsNav?.isApiDocsView
|
|
61
|
+
|
|
62
|
+
// Check if this is an internal docs link (starts with / but not external or tab switch)
|
|
63
|
+
const isInternalDocsLink = href?.startsWith('/') && !isExternal && !isTabSwitchLink && docsNav?.isApiDocsView
|
|
64
|
+
|
|
65
|
+
// Extract slug from href - removes /docs/ prefix if present, or just the leading /
|
|
66
|
+
const getSlugFromHref = (path: string): string => {
|
|
67
|
+
let slug = path
|
|
68
|
+
if (slug.startsWith('/docs/')) {
|
|
69
|
+
slug = slug.slice(6) // Remove '/docs/'
|
|
70
|
+
} else if (slug.startsWith('/')) {
|
|
71
|
+
slug = slug.slice(1) // Remove leading '/'
|
|
72
|
+
}
|
|
73
|
+
return slug
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Get tab ID from href
|
|
77
|
+
const getTabIdFromHref = (path: string): string => {
|
|
78
|
+
if (path === '/api-reference') return 'api-reference'
|
|
79
|
+
if (path === '/changelog') return 'changelog'
|
|
80
|
+
return 'docs'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Handle click for internal navigation
|
|
84
|
+
const handleClick = (e: React.MouseEvent) => {
|
|
85
|
+
if (!href || !docsNav) return
|
|
86
|
+
|
|
87
|
+
if (isTabSwitchLink) {
|
|
88
|
+
e.preventDefault()
|
|
89
|
+
const tabId = getTabIdFromHref(href)
|
|
90
|
+
docsNav.switchToTab(tabId)
|
|
91
|
+
} else if (isInternalDocsLink) {
|
|
92
|
+
e.preventDefault()
|
|
93
|
+
const slug = getSlugFromHref(href)
|
|
94
|
+
docsNav.navigateToPage(slug)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const showArrow = arrow ?? isExternal
|
|
98
|
+
|
|
99
|
+
const cardContent = (
|
|
100
|
+
<div
|
|
101
|
+
className={cn(
|
|
102
|
+
'docs-card group relative rounded-lg border border-border bg-card p-4 transition-all h-full',
|
|
103
|
+
href && 'hover:border-primary/50 hover:shadow-md cursor-pointer',
|
|
104
|
+
horizontal ? 'docs-card-horizontal flex items-start gap-4' : 'flex flex-col justify-start',
|
|
105
|
+
className
|
|
106
|
+
)}
|
|
107
|
+
>
|
|
108
|
+
{/* Image */}
|
|
109
|
+
{img && !horizontal && (
|
|
110
|
+
<div className="mb-4 -mx-4 -mt-4 overflow-hidden rounded-t-lg">
|
|
111
|
+
<img
|
|
112
|
+
src={img}
|
|
113
|
+
alt={title}
|
|
114
|
+
className="w-full h-auto object-cover"
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
|
|
119
|
+
{/* Icon */}
|
|
120
|
+
{Icon && (
|
|
121
|
+
<div
|
|
122
|
+
className={cn(
|
|
123
|
+
'docs-card-icon flex h-10 w-10 shrink-0 items-center justify-center rounded-lg',
|
|
124
|
+
'bg-primary/10 text-primary',
|
|
125
|
+
horizontal && 'mt-0.5'
|
|
126
|
+
)}
|
|
127
|
+
>
|
|
128
|
+
<Icon className="h-5 w-5" weight="duotone" />
|
|
129
|
+
</div>
|
|
130
|
+
)}
|
|
131
|
+
|
|
132
|
+
{/* Content */}
|
|
133
|
+
<div className={cn('docs-card-content min-w-0', horizontal && 'flex-1', !horizontal && Icon && 'mt-3')}>
|
|
134
|
+
<div className="flex items-center gap-2">
|
|
135
|
+
<h3 className="docs-card-title font-semibold text-foreground group-hover:text-primary transition-colors">
|
|
136
|
+
{title}
|
|
137
|
+
</h3>
|
|
138
|
+
{showArrow && (
|
|
139
|
+
isExternal ? (
|
|
140
|
+
<ArrowSquareOut className="h-4 w-4 text-muted-foreground" />
|
|
141
|
+
) : (
|
|
142
|
+
<ArrowRight className="h-4 w-4 text-muted-foreground opacity-0 -translate-x-2 group-hover:opacity-100 group-hover:translate-x-0 transition-all" />
|
|
143
|
+
)
|
|
144
|
+
)}
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
{children && (
|
|
148
|
+
<div className="docs-card-description mt-1 text-sm text-muted-foreground">
|
|
149
|
+
{children}
|
|
150
|
+
</div>
|
|
151
|
+
)}
|
|
152
|
+
|
|
153
|
+
{cta && (
|
|
154
|
+
<div className="docs-card-cta mt-3 text-sm font-medium text-primary">
|
|
155
|
+
{cta}
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
if (href) {
|
|
163
|
+
if (isExternal) {
|
|
164
|
+
return (
|
|
165
|
+
<a href={href} target="_blank" rel="noopener noreferrer" className="docs-card-link block h-full">
|
|
166
|
+
{cardContent}
|
|
167
|
+
</a>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// For internal docs links or tab switch links in ApiDocs view, use click handler
|
|
172
|
+
if (isInternalDocsLink || isTabSwitchLink) {
|
|
173
|
+
return (
|
|
174
|
+
<a href={href} onClick={handleClick} className="docs-card-link block h-full cursor-pointer">
|
|
175
|
+
{cardContent}
|
|
176
|
+
</a>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Standard Next.js Link for all other internal links
|
|
181
|
+
return (
|
|
182
|
+
<Link href={href} className="docs-card-link block h-full">
|
|
183
|
+
{cardContent}
|
|
184
|
+
</Link>
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return cardContent
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface CardGroupProps {
|
|
192
|
+
children: React.ReactNode
|
|
193
|
+
cols?: 1 | 2 | 3 | 4
|
|
194
|
+
className?: string
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function CardGroup({ children, cols = 2, className }: CardGroupProps) {
|
|
198
|
+
const gridCols = {
|
|
199
|
+
1: 'grid-cols-1',
|
|
200
|
+
2: 'grid-cols-1 sm:grid-cols-2',
|
|
201
|
+
3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3',
|
|
202
|
+
4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4',
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<div className={cn('docs-card-group grid gap-4 my-4', gridCols[cols], className)}>
|
|
207
|
+
{children}
|
|
208
|
+
</div>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Alias for Mintlify compatibility
|
|
213
|
+
export { CardGroup as Columns }
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { ReactNode } from 'react'
|
|
4
|
+
import { Warning } from '@phosphor-icons/react'
|
|
5
|
+
import { cn } from '@/lib/utils'
|
|
6
|
+
|
|
7
|
+
interface ChangelogEntryProps {
|
|
8
|
+
version: string
|
|
9
|
+
date: string
|
|
10
|
+
children: ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ChangelogEntry({ version, date, children }: ChangelogEntryProps) {
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
data-version={version}
|
|
17
|
+
className="flex gap-6 lg:gap-10 py-8 border-b border-border last:border-b-0"
|
|
18
|
+
>
|
|
19
|
+
{/* Left column - Version and date */}
|
|
20
|
+
<div className="w-24 lg:w-32 shrink-0">
|
|
21
|
+
<span className="inline-block px-2.5 py-1 text-sm font-medium rounded-md bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400 border border-amber-200 dark:border-amber-800">
|
|
22
|
+
{version}
|
|
23
|
+
</span>
|
|
24
|
+
<p className="mt-2 text-sm text-muted-foreground">{date}</p>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
{/* Right column - Content */}
|
|
28
|
+
<div className="flex-1 min-w-0">
|
|
29
|
+
{children}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ChangelogTitleProps {
|
|
36
|
+
children: ReactNode
|
|
37
|
+
className?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function ChangelogTitle({ children, className }: ChangelogTitleProps) {
|
|
41
|
+
return (
|
|
42
|
+
<h2 className={cn("text-xl font-semibold text-foreground mb-3", className)}>
|
|
43
|
+
{children}
|
|
44
|
+
</h2>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface ChangelogDescriptionProps {
|
|
49
|
+
children: ReactNode
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function ChangelogDescription({ children }: ChangelogDescriptionProps) {
|
|
53
|
+
return (
|
|
54
|
+
<p className="text-muted-foreground mb-4">
|
|
55
|
+
{children}
|
|
56
|
+
</p>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface ChangelogImageProps {
|
|
61
|
+
src: string
|
|
62
|
+
alt?: string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function ChangelogImage({ src, alt = "Screenshot" }: ChangelogImageProps) {
|
|
66
|
+
return (
|
|
67
|
+
<div className="my-6 rounded-lg border border-border overflow-hidden shadow-sm">
|
|
68
|
+
<img src={src} alt={alt} className="w-full" />
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface BreakingChangeProps {
|
|
74
|
+
children: ReactNode
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function BreakingChange({ children }: BreakingChangeProps) {
|
|
78
|
+
return (
|
|
79
|
+
<div className="my-6 flex gap-3 p-4 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800">
|
|
80
|
+
<Warning className="h-5 w-5 text-amber-600 dark:text-amber-500 shrink-0 mt-0.5" weight="fill" />
|
|
81
|
+
<div className="text-amber-800 dark:text-amber-200 text-sm">
|
|
82
|
+
{children}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface MoreUpdatesProps {
|
|
89
|
+
children: ReactNode
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function MoreUpdates({ children }: MoreUpdatesProps) {
|
|
93
|
+
return (
|
|
94
|
+
<div className="mt-6">
|
|
95
|
+
<h3 className="text-lg font-semibold text-foreground mb-3">More Updates</h3>
|
|
96
|
+
<ul className="space-y-2 text-muted-foreground">
|
|
97
|
+
{children}
|
|
98
|
+
</ul>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface UpdateItemProps {
|
|
104
|
+
children: ReactNode
|
|
105
|
+
type?: 'default' | 'behavior'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function UpdateItem({ children, type = 'default' }: UpdateItemProps) {
|
|
109
|
+
return (
|
|
110
|
+
<li className="flex items-start gap-2">
|
|
111
|
+
<span className="mt-2 h-1.5 w-1.5 rounded-full bg-foreground shrink-0" />
|
|
112
|
+
<span>
|
|
113
|
+
{type === 'behavior' && (
|
|
114
|
+
<strong className="font-semibold text-foreground">Behavior Change </strong>
|
|
115
|
+
)}
|
|
116
|
+
{children}
|
|
117
|
+
</span>
|
|
118
|
+
</li>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React, { useState, isValidElement, ReactNode, createContext, useContext } from 'react'
|
|
4
|
+
import { cn } from '@/lib/utils'
|
|
5
|
+
import { Copy, Check } from '@phosphor-icons/react'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pre and Code components for code block styling
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Context to detect if we're inside a CodeGroup
|
|
12
|
+
export const CodeGroupContext = createContext(false)
|
|
13
|
+
|
|
14
|
+
// Extract text content from nested React elements
|
|
15
|
+
function extractTextContent(node: ReactNode): string {
|
|
16
|
+
if (typeof node === 'string') return node
|
|
17
|
+
if (typeof node === 'number') return String(node)
|
|
18
|
+
if (Array.isArray(node)) return node.map(extractTextContent).join('')
|
|
19
|
+
if (isValidElement(node)) {
|
|
20
|
+
const props = node.props as { children?: ReactNode }
|
|
21
|
+
if (props.children) {
|
|
22
|
+
return extractTextContent(props.children)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return ''
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Get display name for language
|
|
29
|
+
function getDisplayName(language: string): string {
|
|
30
|
+
const displayNames: Record<string, string> = {
|
|
31
|
+
javascript: 'JavaScript',
|
|
32
|
+
typescript: 'TypeScript',
|
|
33
|
+
python: 'Python',
|
|
34
|
+
java: 'Java',
|
|
35
|
+
go: 'Go',
|
|
36
|
+
rust: 'Rust',
|
|
37
|
+
ruby: 'Ruby',
|
|
38
|
+
php: 'PHP',
|
|
39
|
+
csharp: 'C#',
|
|
40
|
+
cpp: 'C++',
|
|
41
|
+
c: 'C',
|
|
42
|
+
swift: 'Swift',
|
|
43
|
+
kotlin: 'Kotlin',
|
|
44
|
+
bash: 'Bash',
|
|
45
|
+
shell: 'Shell',
|
|
46
|
+
json: 'JSON',
|
|
47
|
+
yaml: 'YAML',
|
|
48
|
+
html: 'HTML',
|
|
49
|
+
css: 'CSS',
|
|
50
|
+
sql: 'SQL',
|
|
51
|
+
markdown: 'Markdown',
|
|
52
|
+
text: 'Text',
|
|
53
|
+
plaintext: 'Text',
|
|
54
|
+
}
|
|
55
|
+
return displayNames[language.toLowerCase()] || language.charAt(0).toUpperCase() + language.slice(1)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Pre - Code block wrapper component
|
|
60
|
+
* Styled to match CodeGroup default variant
|
|
61
|
+
*/
|
|
62
|
+
interface PreProps extends React.HTMLAttributes<HTMLPreElement> {
|
|
63
|
+
children?: ReactNode
|
|
64
|
+
'data-language'?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function Pre({ children, className, 'data-language': dataLanguage, ...props }: PreProps) {
|
|
68
|
+
const isInCodeGroup = useContext(CodeGroupContext)
|
|
69
|
+
const [copied, setCopied] = useState(false)
|
|
70
|
+
|
|
71
|
+
// If inside CodeGroup, render plain pre (CodeGroup handles styling)
|
|
72
|
+
if (isInCodeGroup) {
|
|
73
|
+
return (
|
|
74
|
+
<pre className={cn('overflow-x-auto', className)} {...props}>
|
|
75
|
+
{children}
|
|
76
|
+
</pre>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Extract language from children's className or data attribute
|
|
81
|
+
let language = dataLanguage || 'text'
|
|
82
|
+
let content = ''
|
|
83
|
+
|
|
84
|
+
if (isValidElement(children)) {
|
|
85
|
+
const childProps = children.props as { className?: string; children?: ReactNode }
|
|
86
|
+
const childClassName = childProps.className || ''
|
|
87
|
+
const match = childClassName.match(/language-(\w+)/)
|
|
88
|
+
if (match) {
|
|
89
|
+
language = match[1]
|
|
90
|
+
}
|
|
91
|
+
content = extractTextContent(childProps.children)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleCopy = async () => {
|
|
95
|
+
try {
|
|
96
|
+
await navigator.clipboard.writeText(content.trim())
|
|
97
|
+
setCopied(true)
|
|
98
|
+
setTimeout(() => setCopied(false), 2000)
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error('Failed to copy:', err)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const displayName = getDisplayName(language)
|
|
105
|
+
|
|
106
|
+
// Standalone code block - styled like CodeGroup
|
|
107
|
+
return (
|
|
108
|
+
<div className="docs-code-block my-4 rounded-xl border border-zinc-800 overflow-hidden bg-[#1a1a1a]">
|
|
109
|
+
{/* Header */}
|
|
110
|
+
<div className="docs-code-header flex items-center justify-between bg-[#262626] px-2">
|
|
111
|
+
<div className="flex overflow-x-auto">
|
|
112
|
+
<div className="docs-code-tab px-4 py-2.5 text-sm font-medium whitespace-nowrap text-white relative">
|
|
113
|
+
{displayName}
|
|
114
|
+
<span className="absolute bottom-0 left-0 right-0 h-0.5 bg-emerald-500 rounded-full" />
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
{/* Copy button */}
|
|
119
|
+
<div className="docs-code-actions flex items-center gap-1 pr-2">
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
onClick={handleCopy}
|
|
123
|
+
className={cn(
|
|
124
|
+
'p-1.5 rounded text-zinc-500 hover:text-zinc-300',
|
|
125
|
+
'hover:bg-zinc-700/50 transition-colors',
|
|
126
|
+
'focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50'
|
|
127
|
+
)}
|
|
128
|
+
title="Copy code"
|
|
129
|
+
>
|
|
130
|
+
{copied ? (
|
|
131
|
+
<Check className="h-4 w-4 text-emerald-500" weight="bold" />
|
|
132
|
+
) : (
|
|
133
|
+
<Copy className="h-4 w-4" />
|
|
134
|
+
)}
|
|
135
|
+
</button>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
{/* Code content */}
|
|
140
|
+
<div className="docs-code-content overflow-x-auto">
|
|
141
|
+
<pre
|
|
142
|
+
className={cn(
|
|
143
|
+
'p-4 m-0 bg-transparent text-sm',
|
|
144
|
+
className
|
|
145
|
+
)}
|
|
146
|
+
{...props}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
</pre>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Code - Inline code styling
|
|
157
|
+
*/
|
|
158
|
+
interface CodeProps extends React.HTMLAttributes<HTMLElement> {
|
|
159
|
+
children?: ReactNode
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function Code({ children, className, ...props }: CodeProps) {
|
|
163
|
+
const isCodeBlock = className?.includes('language-')
|
|
164
|
+
|
|
165
|
+
if (isCodeBlock) {
|
|
166
|
+
return (
|
|
167
|
+
<code className={cn(className, 'bg-transparent')} {...props}>
|
|
168
|
+
{children}
|
|
169
|
+
</code>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Inline code
|
|
174
|
+
return (
|
|
175
|
+
<code
|
|
176
|
+
className={cn(
|
|
177
|
+
'docs-inline-code px-1.5 py-0.5 rounded text-sm font-mono',
|
|
178
|
+
'bg-zinc-800 text-zinc-200',
|
|
179
|
+
className
|
|
180
|
+
)}
|
|
181
|
+
{...props}
|
|
182
|
+
>
|
|
183
|
+
{children}
|
|
184
|
+
</code>
|
|
185
|
+
)
|
|
186
|
+
}
|