@barodoc/theme-docs 6.0.0 → 7.0.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 +2 -2
- package/src/components/Contributors.astro +32 -16
- package/src/components/DocHeader.tsx +29 -1
- package/src/components/Header.astro +1 -0
- package/src/components/MobileNav.astro +2 -0
- package/src/components/MobileNavSheet.tsx +29 -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/layouts/BlogLayout.astro +16 -2
- package/src/pages/blog/[...slug].astro +1 -0
- package/src/pages/blog/index.astro +12 -1
- package/src/pages/docs/[...slug].astro +1 -1
- package/src/pages/index.astro +18 -4
- package/src/styles/global.css +998 -114
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barodoc/theme-docs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Documentation theme for Barodoc",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"rehype-katex": "^7.0.1",
|
|
35
35
|
"remark-math": "^6.0.0",
|
|
36
36
|
"tailwind-merge": "^3.4.0",
|
|
37
|
-
"@barodoc/core": "
|
|
37
|
+
"@barodoc/core": "7.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"astro": "^5.0.0",
|
|
@@ -27,11 +27,21 @@ if (filePath) {
|
|
|
27
27
|
for (const line of raw.split("\n")) {
|
|
28
28
|
const [name, email] = line.split("|");
|
|
29
29
|
if (!name || seen.has(email)) continue;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
|
|
31
|
+
const trimmedEmail = email.trim();
|
|
32
|
+
const trimmedName = name.trim();
|
|
33
|
+
|
|
34
|
+
const noreplyMatch = trimmedEmail.match(
|
|
35
|
+
/^(\d+\+)?([^@]+)@users\.noreply\.github\.com$/
|
|
36
|
+
);
|
|
37
|
+
const avatarUrl = noreplyMatch
|
|
38
|
+
? `https://github.com/${noreplyMatch[2]}.png?size=64`
|
|
39
|
+
: `https://gravatar.com/avatar/${await computeHash(trimmedEmail.toLowerCase())}?s=64&d=mp`;
|
|
40
|
+
|
|
41
|
+
seen.set(trimmedEmail, {
|
|
42
|
+
name: trimmedName,
|
|
43
|
+
email: trimmedEmail,
|
|
44
|
+
avatarUrl,
|
|
35
45
|
});
|
|
36
46
|
}
|
|
37
47
|
contributors = Array.from(seen.values());
|
|
@@ -55,17 +65,23 @@ async function computeHash(input: string): Promise<string> {
|
|
|
55
65
|
<div class="bd-contributors">
|
|
56
66
|
<span class="bd-contributors-label">Contributors</span>
|
|
57
67
|
<div class="bd-contributors-avatars">
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
<img
|
|
69
|
+
src={contributors[0].avatarUrl}
|
|
70
|
+
alt={contributors[0].name}
|
|
71
|
+
title={contributors[0].name}
|
|
72
|
+
class="bd-contributor-avatar"
|
|
73
|
+
loading="lazy"
|
|
74
|
+
width="28"
|
|
75
|
+
height="28"
|
|
76
|
+
/>
|
|
77
|
+
{contributors.length > 1 && (
|
|
78
|
+
<span
|
|
79
|
+
class="bd-contributor-count"
|
|
80
|
+
title={contributors.slice(1).map((c) => c.name).join(", ")}
|
|
81
|
+
>
|
|
82
|
+
+{contributors.length - 1}
|
|
83
|
+
</span>
|
|
84
|
+
)}
|
|
69
85
|
</div>
|
|
70
86
|
</div>
|
|
71
87
|
)}
|
|
@@ -10,9 +10,15 @@ import {
|
|
|
10
10
|
} from "./ui/tooltip";
|
|
11
11
|
import { cn } from "../lib/utils";
|
|
12
12
|
|
|
13
|
+
interface TabItem {
|
|
14
|
+
label: string;
|
|
15
|
+
href: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
interface DocHeaderProps {
|
|
14
19
|
siteName: string;
|
|
15
20
|
logo?: string;
|
|
21
|
+
tabs?: TabItem[];
|
|
16
22
|
githubUrl?: string;
|
|
17
23
|
hasMultipleLocales?: boolean;
|
|
18
24
|
currentLocale?: string;
|
|
@@ -46,6 +52,7 @@ function getLocalizedUrl(
|
|
|
46
52
|
export function DocHeader({
|
|
47
53
|
siteName,
|
|
48
54
|
logo,
|
|
55
|
+
tabs = [],
|
|
49
56
|
githubUrl,
|
|
50
57
|
hasMultipleLocales,
|
|
51
58
|
currentLocale = "en",
|
|
@@ -92,7 +99,7 @@ export function DocHeader({
|
|
|
92
99
|
<TooltipProvider>
|
|
93
100
|
<header className="sticky top-0 z-50 w-full min-w-0 border-b border-[var(--bd-border)] bg-[var(--bd-bg)]/95 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--bd-bg)]/80">
|
|
94
101
|
<div className="flex h-14 items-center justify-between gap-2 px-4 sm:px-6 max-w-[1280px] mx-auto min-w-0">
|
|
95
|
-
{/* Logo */}
|
|
102
|
+
{/* Logo + Tabs */}
|
|
96
103
|
<div className="flex items-center gap-6 min-w-0 shrink">
|
|
97
104
|
<a
|
|
98
105
|
href="/"
|
|
@@ -101,6 +108,27 @@ export function DocHeader({
|
|
|
101
108
|
{logo && <img src={logo} alt={siteName} className="h-7 w-7 shrink-0" />}
|
|
102
109
|
<span className="text-[15px] tracking-tight truncate">{siteName}</span>
|
|
103
110
|
</a>
|
|
111
|
+
{tabs.length > 0 && (
|
|
112
|
+
<nav className="hidden md:flex items-center gap-1">
|
|
113
|
+
{tabs.map((tab) => {
|
|
114
|
+
const isActive = currentPath === tab.href || currentPath.startsWith(tab.href + "/");
|
|
115
|
+
return (
|
|
116
|
+
<a
|
|
117
|
+
key={tab.href}
|
|
118
|
+
href={tab.href}
|
|
119
|
+
className={cn(
|
|
120
|
+
"px-3 py-1.5 text-[13px] font-medium rounded-lg transition-colors",
|
|
121
|
+
isActive
|
|
122
|
+
? "text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-950/50"
|
|
123
|
+
: "text-[var(--bd-text-secondary)] hover:text-[var(--bd-text)] hover:bg-[var(--bd-bg-subtle)]"
|
|
124
|
+
)}
|
|
125
|
+
>
|
|
126
|
+
{tab.label}
|
|
127
|
+
</a>
|
|
128
|
+
);
|
|
129
|
+
})}
|
|
130
|
+
</nav>
|
|
131
|
+
)}
|
|
104
132
|
</div>
|
|
105
133
|
|
|
106
134
|
{/* Right side actions */}
|
|
@@ -18,6 +18,7 @@ const localeLabels: Record<string, string> = config.i18n?.labels || {};
|
|
|
18
18
|
client:load
|
|
19
19
|
siteName={config.name}
|
|
20
20
|
logo={config.logo}
|
|
21
|
+
tabs={config.tabs}
|
|
21
22
|
githubUrl={config.topbar?.github}
|
|
22
23
|
hasMultipleLocales={hasMultipleLocales}
|
|
23
24
|
currentLocale={currentLocale}
|
|
@@ -21,13 +21,20 @@ interface NavGroup {
|
|
|
21
21
|
defaultOpen?: boolean;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
interface TabItem {
|
|
25
|
+
label: string;
|
|
26
|
+
href: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
interface MobileNavSheetProps {
|
|
25
30
|
groups: NavGroup[];
|
|
26
31
|
siteName: string;
|
|
27
32
|
logo?: string;
|
|
33
|
+
tabs?: TabItem[];
|
|
34
|
+
currentPath?: string;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
export function MobileNavSheet({ groups, siteName, logo }: MobileNavSheetProps) {
|
|
37
|
+
export function MobileNavSheet({ groups, siteName, logo, tabs = [], currentPath = "" }: MobileNavSheetProps) {
|
|
31
38
|
const [open, setOpen] = React.useState(false);
|
|
32
39
|
|
|
33
40
|
React.useEffect(() => {
|
|
@@ -61,6 +68,27 @@ export function MobileNavSheet({ groups, siteName, logo }: MobileNavSheetProps)
|
|
|
61
68
|
</SheetTitle>
|
|
62
69
|
</SheetHeader>
|
|
63
70
|
<ScrollArea className="h-[calc(100vh-65px)]">
|
|
71
|
+
{tabs.length > 0 && (
|
|
72
|
+
<div className="px-4 pt-4 pb-2 flex flex-col gap-1 border-b border-[var(--bd-border)]">
|
|
73
|
+
{tabs.map((tab) => {
|
|
74
|
+
const isActive = currentPath === tab.href || currentPath.startsWith(tab.href + "/");
|
|
75
|
+
return (
|
|
76
|
+
<a
|
|
77
|
+
key={tab.href}
|
|
78
|
+
href={tab.href}
|
|
79
|
+
className={cn(
|
|
80
|
+
"px-3 py-2 text-sm font-medium rounded-lg transition-colors",
|
|
81
|
+
isActive
|
|
82
|
+
? "text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-950/50"
|
|
83
|
+
: "text-[var(--bd-text-secondary)] hover:text-[var(--bd-text)] hover:bg-[var(--bd-bg-subtle)]"
|
|
84
|
+
)}
|
|
85
|
+
>
|
|
86
|
+
{tab.label}
|
|
87
|
+
</a>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
</div>
|
|
91
|
+
)}
|
|
64
92
|
<div className="px-2 py-4">
|
|
65
93
|
<DocsSidebar groups={groups} />
|
|
66
94
|
</div>
|
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
|
+
}
|