@barodoc/theme-docs 6.0.0 → 6.1.0
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/package.json +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/mdx/ApiEndpoint.tsx +35 -0
- package/src/components/mdx/ApiPlayground.tsx +650 -61
- package/src/styles/global.css +981 -113
package/package.json
CHANGED
package/src/components/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { Mermaid } from "./mdx/Mermaid.tsx";
|
|
|
27
27
|
export { ImageZoom } from "./mdx/ImageZoom.tsx";
|
|
28
28
|
export { Video } from "./mdx/Video.tsx";
|
|
29
29
|
export { ApiPlayground } from "./mdx/ApiPlayground.tsx";
|
|
30
|
+
export { ApiEndpoint } from "./mdx/ApiEndpoint.tsx";
|
|
30
31
|
|
|
31
32
|
export { VersionSwitcher } from "./VersionSwitcher.tsx";
|
|
32
33
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
|
|
4
|
+
interface ApiEndpointProps {
|
|
5
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
6
|
+
path: string;
|
|
7
|
+
summary?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const METHOD_COLORS: Record<string, string> = {
|
|
12
|
+
GET: "bd-method-get",
|
|
13
|
+
POST: "bd-method-post",
|
|
14
|
+
PUT: "bd-method-put",
|
|
15
|
+
PATCH: "bd-method-patch",
|
|
16
|
+
DELETE: "bd-method-delete",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function ApiEndpoint({ method, path, summary, id }: ApiEndpointProps) {
|
|
20
|
+
const slug = id || `${method.toLowerCase()}-${path.replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/g, "")}`;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="bd-api-endpoint" id={slug}>
|
|
24
|
+
<a href={`#${slug}`} className="bd-api-endpoint-anchor" aria-label={`${method} ${path}`}>
|
|
25
|
+
<div className="bd-api-endpoint-header">
|
|
26
|
+
<span className={cn("bd-api-endpoint-method", METHOD_COLORS[method])}>
|
|
27
|
+
{method}
|
|
28
|
+
</span>
|
|
29
|
+
<code className="bd-api-endpoint-path">{path}</code>
|
|
30
|
+
</div>
|
|
31
|
+
{summary && <p className="bd-api-endpoint-summary">{summary}</p>}
|
|
32
|
+
</a>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|