@docubook/mdx 1.0.0 → 1.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/README.md +121 -0
- package/dist/{Stepper-B7xt0Dyr.d.cts → Stepper-I9nywkZb.d.cts} +1 -1
- package/dist/{Stepper-B7xt0Dyr.d.ts → Stepper-I9nywkZb.d.ts} +1 -1
- package/dist/adapters/next/index.cjs +8 -6
- package/dist/adapters/next/index.js +8 -6
- package/dist/adapters/react-router/index.cjs +8 -6
- package/dist/adapters/react-router/index.js +8 -6
- package/dist/core/index.cjs +262 -116
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +273 -127
- package/dist/core/server.cjs +74 -36
- package/dist/core/server.d.cts +2 -2
- package/dist/core/server.d.ts +2 -2
- package/dist/core/server.js +74 -36
- package/dist/index.cjs +74 -36
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +74 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
Framework-agnostic MDX components for React with adapter entrypoints.
|
|
4
4
|
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Install from npm registry:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @docubook/mdx
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @docubook/mdx
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add @docubook/mdx
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bun add @docubook/mdx
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you are using a pnpm workspace/monorepo and want to add it to a specific app package, run the command from that app directory, or use filter:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm --filter <your-app-package-name> add @docubook/mdx
|
|
29
|
+
```
|
|
30
|
+
|
|
5
31
|
## Entrypoints
|
|
6
32
|
|
|
7
33
|
- `@docubook/mdx`: server-safe convenience export (alias to subset `core/server`).
|
|
@@ -106,6 +132,101 @@ Use this as practical guidance for helper imports:
|
|
|
106
132
|
| NextImageMdx | Adapter (Next.js) | `@docubook/mdx/next` | For `img` mapping in Next App Router. |
|
|
107
133
|
| NextLinkMdx | Adapter (Next.js) | `@docubook/mdx/next` | For `a` mapping in Next App Router. |
|
|
108
134
|
|
|
135
|
+
## Styling Override (Backward Compatible)
|
|
136
|
+
|
|
137
|
+
Default styling in `core` follows the same base look as the `nextjs-vercel` markdown components for backward compatibility.
|
|
138
|
+
|
|
139
|
+
Best practice: override styles globally using the built-in semantic hooks (`data-docubook` and `dbk-*` classes) in your app stylesheet, so you do not need to add `className` in MDX content.
|
|
140
|
+
|
|
141
|
+
### Global Override Example (recommended)
|
|
142
|
+
|
|
143
|
+
Use in `styles/globals.css` or `styles/override.css`:
|
|
144
|
+
|
|
145
|
+
```css
|
|
146
|
+
/* Accordion */
|
|
147
|
+
[data-docubook="accordion-button"] {
|
|
148
|
+
@apply bg-blue-50 hover:bg-blue-100;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
[data-docubook="accordion-title"] {
|
|
152
|
+
@apply text-blue-900 font-semibold;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Note */
|
|
156
|
+
[data-docubook="note"][data-variant="warning"] {
|
|
157
|
+
@apply border-amber-400/50 bg-amber-50 text-amber-900;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* Tooltip */
|
|
161
|
+
[data-docubook="tooltip-content"] {
|
|
162
|
+
@apply w-80 text-xs;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* File tree */
|
|
166
|
+
[data-docubook="file-tree"] {
|
|
167
|
+
@apply border-blue-200;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
[data-docubook="file-tree-folder-button"] {
|
|
171
|
+
@apply py-2;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Selector Table For Override
|
|
176
|
+
|
|
177
|
+
Use `data-docubook` selectors as the primary (stable) target, and use `dbk-*` classes as a fallback when needed.
|
|
178
|
+
|
|
179
|
+
| Component | Target Element | Stable Selector (`data-docubook`) | Class Hook (`dbk-*`) |
|
|
180
|
+
| --- | --- | --- | --- |
|
|
181
|
+
| Accordion | Root | `[data-docubook="accordion"]` | `.dbk-accordion` |
|
|
182
|
+
| Accordion | Trigger Button | `[data-docubook="accordion-button"]` | `.dbk-accordion__button` |
|
|
183
|
+
| Accordion | Chevron | `[data-docubook="accordion-chevron"]` | `.dbk-accordion__chevron` |
|
|
184
|
+
| Accordion | Title | `[data-docubook="accordion-title"]` | `.dbk-accordion__title` |
|
|
185
|
+
| Accordion | Content Body | `[data-docubook="accordion-content-body"]` | `.dbk-accordion__content-body` |
|
|
186
|
+
| AccordionGroup | Root | `[data-docubook="accordion-group"]` | `.dbk-accordion-group` |
|
|
187
|
+
| Note | Root | `[data-docubook="note"]` | `.dbk-note` |
|
|
188
|
+
| Note | Variant Warning | `[data-docubook="note"][data-variant="warning"]` | `.dbk-note[data-variant="warning"]` |
|
|
189
|
+
| Note | Title | `[data-docubook="note-title"]` | `.dbk-note__title` |
|
|
190
|
+
| Stepper | Root | `[data-docubook="stepper"]` | `.dbk-stepper` |
|
|
191
|
+
| Stepper | Item | `[data-docubook="stepper-item"]` | `.dbk-stepper__item` |
|
|
192
|
+
| Stepper | Number | `[data-docubook="stepper-number"]` | `.dbk-stepper__number` |
|
|
193
|
+
| StepperItem | Title | `[data-docubook="stepper-item-title"]` | `.dbk-stepper-item__title` |
|
|
194
|
+
| Tooltip | Root | `[data-docubook="tooltip"]` | `.dbk-tooltip` |
|
|
195
|
+
| Tooltip | Trigger | `[data-docubook="tooltip-trigger"]` | `.dbk-tooltip__trigger` |
|
|
196
|
+
| Tooltip | Content | `[data-docubook="tooltip-content"]` | `.dbk-tooltip__content` |
|
|
197
|
+
| FileTree | Root | `[data-docubook="file-tree"]` | `.dbk-file-tree` |
|
|
198
|
+
| FileTree | Folder Button | `[data-docubook="file-tree-folder-button"]` | `.dbk-file-tree__folder-button` |
|
|
199
|
+
| FileTree | Folder Children | `[data-docubook="file-tree-folder-children"]` | `.dbk-file-tree__folder-children` |
|
|
200
|
+
| FileTree | File Row | `[data-docubook="file-tree-file"]` | `.dbk-file-tree__file` |
|
|
201
|
+
| Card | Root | `[data-docubook="card"]` | `.dbk-card` |
|
|
202
|
+
| Card | Link Wrapper | `[data-docubook="card-link"]` | `.dbk-card__link` |
|
|
203
|
+
| Card | Title | `[data-docubook="card-title"]` | `.dbk-card__title` |
|
|
204
|
+
| Copy | Button | `[data-docubook="copy-button"]` | `.dbk-copy` |
|
|
205
|
+
| Copy | Icon | `[data-docubook="copy-icon"]` | `.dbk-copy__icon` |
|
|
206
|
+
| Keyboard (Kbd) | Root | `[data-docubook="kbd"]` | `.dbk-kbd` |
|
|
207
|
+
| Release | Root | `[data-docubook="release"]` | `.dbk-release` |
|
|
208
|
+
| Release | Version Badge | `[data-docubook="release-version"]` | `.dbk-release__version` |
|
|
209
|
+
| Release | Title | `[data-docubook="release-title"]` | `.dbk-release__title` |
|
|
210
|
+
| Changes | Root | `[data-docubook="release-changes"]` | `.dbk-release-changes` |
|
|
211
|
+
| Changes | Badge | `[data-docubook="release-changes-badge"]` | `.dbk-release-changes__badge` |
|
|
212
|
+
| Changes | Item | `[data-docubook="release-changes-item"]` | `.dbk-release-changes__item` |
|
|
213
|
+
|
|
214
|
+
Quick example:
|
|
215
|
+
|
|
216
|
+
```css
|
|
217
|
+
[data-docubook="card-title"] {
|
|
218
|
+
@apply text-blue-700;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[data-docubook="copy-button"] {
|
|
222
|
+
@apply rounded-lg border-blue-300;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
[data-docubook="release-changes"][data-type="improved"] [data-docubook="release-changes-badge"] {
|
|
226
|
+
@apply bg-sky-100 text-sky-700;
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
109
230
|
## Loading Strategy (Helper)
|
|
110
231
|
|
|
111
232
|
- Prefer static import for high-frequency primitives: `a`, `img`, `pre`.
|
|
@@ -45,7 +45,7 @@ interface ChangesProps extends PropsWithChildren {
|
|
|
45
45
|
}
|
|
46
46
|
declare function Changes({ type, children }: ChangesProps): react_jsx_runtime.JSX.Element;
|
|
47
47
|
|
|
48
|
-
declare function Stepper({ children }: PropsWithChildren): react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare function Stepper({ children, }: PropsWithChildren): react_jsx_runtime.JSX.Element;
|
|
49
49
|
declare function StepperItem({ children, title, }: PropsWithChildren & {
|
|
50
50
|
title?: string;
|
|
51
51
|
}): react_jsx_runtime.JSX.Element;
|
|
@@ -45,7 +45,7 @@ interface ChangesProps extends PropsWithChildren {
|
|
|
45
45
|
}
|
|
46
46
|
declare function Changes({ type, children }: ChangesProps): react_jsx_runtime.JSX.Element;
|
|
47
47
|
|
|
48
|
-
declare function Stepper({ children }: PropsWithChildren): react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare function Stepper({ children, }: PropsWithChildren): react_jsx_runtime.JSX.Element;
|
|
49
49
|
declare function StepperItem({ children, title, }: PropsWithChildren & {
|
|
50
50
|
title?: string;
|
|
51
51
|
}): react_jsx_runtime.JSX.Element;
|
|
@@ -110,6 +110,7 @@ function Card({
|
|
|
110
110
|
"div",
|
|
111
111
|
{
|
|
112
112
|
className: (0, import_clsx.default)(
|
|
113
|
+
"dbk-card",
|
|
113
114
|
"border rounded-lg shadow-sm p-4 transition-all duration-200",
|
|
114
115
|
"bg-card text-card-foreground border-border",
|
|
115
116
|
"hover:bg-accent/5 hover:border-accent/30",
|
|
@@ -117,20 +118,21 @@ function Card({
|
|
|
117
118
|
horizontal ? "flex-row items-start gap-1" : "flex-col space-y-1",
|
|
118
119
|
className
|
|
119
120
|
),
|
|
121
|
+
"data-docubook": "card",
|
|
120
122
|
children: [
|
|
121
|
-
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: (0, import_clsx.default)("w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5") }),
|
|
122
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
123
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-base font-semibold text-foreground leading-6", children: title }),
|
|
124
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-sm text-muted-foreground -mt-3", children })
|
|
123
|
+
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: (0, import_clsx.default)("dbk-card__icon", "w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5"), "data-docubook": "card-icon" }),
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dbk-card__body flex-1 min-w-0", "data-docubook": "card-body", children: [
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dbk-card__title text-base font-semibold text-foreground leading-6", "data-docubook": "card-title", children: title }),
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dbk-card__content text-sm text-muted-foreground -mt-3", "data-docubook": "card-content", children })
|
|
125
127
|
] })
|
|
126
128
|
]
|
|
127
129
|
}
|
|
128
130
|
);
|
|
129
131
|
if (!href) return content;
|
|
130
132
|
if (LinkComponent) {
|
|
131
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkComponent, { href, className: "no-underline block", children: content });
|
|
133
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkComponent, { href, className: "dbk-card__link no-underline block", "data-docubook": "card-link", children: content });
|
|
132
134
|
}
|
|
133
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { className: "no-underline block", href, children: content });
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { className: "dbk-card__link no-underline block", href, "data-docubook": "card-link", children: content });
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
// src/adapters/next/index.tsx
|
|
@@ -73,6 +73,7 @@ function Card({
|
|
|
73
73
|
"div",
|
|
74
74
|
{
|
|
75
75
|
className: clsx(
|
|
76
|
+
"dbk-card",
|
|
76
77
|
"border rounded-lg shadow-sm p-4 transition-all duration-200",
|
|
77
78
|
"bg-card text-card-foreground border-border",
|
|
78
79
|
"hover:bg-accent/5 hover:border-accent/30",
|
|
@@ -80,20 +81,21 @@ function Card({
|
|
|
80
81
|
horizontal ? "flex-row items-start gap-1" : "flex-col space-y-1",
|
|
81
82
|
className
|
|
82
83
|
),
|
|
84
|
+
"data-docubook": "card",
|
|
83
85
|
children: [
|
|
84
|
-
Icon && /* @__PURE__ */ jsx2(Icon, { className: clsx("w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5") }),
|
|
85
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex-1 min-w-0", children: [
|
|
86
|
-
/* @__PURE__ */ jsx2("div", { className: "text-base font-semibold text-foreground leading-6", children: title }),
|
|
87
|
-
/* @__PURE__ */ jsx2("div", { className: "text-sm text-muted-foreground -mt-3", children })
|
|
86
|
+
Icon && /* @__PURE__ */ jsx2(Icon, { className: clsx("dbk-card__icon", "w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5"), "data-docubook": "card-icon" }),
|
|
87
|
+
/* @__PURE__ */ jsxs2("div", { className: "dbk-card__body flex-1 min-w-0", "data-docubook": "card-body", children: [
|
|
88
|
+
/* @__PURE__ */ jsx2("div", { className: "dbk-card__title text-base font-semibold text-foreground leading-6", "data-docubook": "card-title", children: title }),
|
|
89
|
+
/* @__PURE__ */ jsx2("div", { className: "dbk-card__content text-sm text-muted-foreground -mt-3", "data-docubook": "card-content", children })
|
|
88
90
|
] })
|
|
89
91
|
]
|
|
90
92
|
}
|
|
91
93
|
);
|
|
92
94
|
if (!href) return content;
|
|
93
95
|
if (LinkComponent) {
|
|
94
|
-
return /* @__PURE__ */ jsx2(LinkComponent, { href, className: "no-underline block", children: content });
|
|
96
|
+
return /* @__PURE__ */ jsx2(LinkComponent, { href, className: "dbk-card__link no-underline block", "data-docubook": "card-link", children: content });
|
|
95
97
|
}
|
|
96
|
-
return /* @__PURE__ */ jsx2("a", { className: "no-underline block", href, children: content });
|
|
98
|
+
return /* @__PURE__ */ jsx2("a", { className: "dbk-card__link no-underline block", href, "data-docubook": "card-link", children: content });
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
// src/adapters/next/index.tsx
|
|
@@ -109,6 +109,7 @@ function Card({
|
|
|
109
109
|
"div",
|
|
110
110
|
{
|
|
111
111
|
className: (0, import_clsx.default)(
|
|
112
|
+
"dbk-card",
|
|
112
113
|
"border rounded-lg shadow-sm p-4 transition-all duration-200",
|
|
113
114
|
"bg-card text-card-foreground border-border",
|
|
114
115
|
"hover:bg-accent/5 hover:border-accent/30",
|
|
@@ -116,20 +117,21 @@ function Card({
|
|
|
116
117
|
horizontal ? "flex-row items-start gap-1" : "flex-col space-y-1",
|
|
117
118
|
className
|
|
118
119
|
),
|
|
120
|
+
"data-docubook": "card",
|
|
119
121
|
children: [
|
|
120
|
-
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: (0, import_clsx.default)("w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5") }),
|
|
121
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
122
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-base font-semibold text-foreground leading-6", children: title }),
|
|
123
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-sm text-muted-foreground -mt-3", children })
|
|
122
|
+
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: (0, import_clsx.default)("dbk-card__icon", "w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5"), "data-docubook": "card-icon" }),
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dbk-card__body flex-1 min-w-0", "data-docubook": "card-body", children: [
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dbk-card__title text-base font-semibold text-foreground leading-6", "data-docubook": "card-title", children: title }),
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dbk-card__content text-sm text-muted-foreground -mt-3", "data-docubook": "card-content", children })
|
|
124
126
|
] })
|
|
125
127
|
]
|
|
126
128
|
}
|
|
127
129
|
);
|
|
128
130
|
if (!href) return content;
|
|
129
131
|
if (LinkComponent) {
|
|
130
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkComponent, { href, className: "no-underline block", children: content });
|
|
132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkComponent, { href, className: "dbk-card__link no-underline block", "data-docubook": "card-link", children: content });
|
|
131
133
|
}
|
|
132
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { className: "no-underline block", href, children: content });
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { className: "dbk-card__link no-underline block", href, "data-docubook": "card-link", children: content });
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
// src/core/components/Image.tsx
|
|
@@ -72,6 +72,7 @@ function Card({
|
|
|
72
72
|
"div",
|
|
73
73
|
{
|
|
74
74
|
className: clsx(
|
|
75
|
+
"dbk-card",
|
|
75
76
|
"border rounded-lg shadow-sm p-4 transition-all duration-200",
|
|
76
77
|
"bg-card text-card-foreground border-border",
|
|
77
78
|
"hover:bg-accent/5 hover:border-accent/30",
|
|
@@ -79,20 +80,21 @@ function Card({
|
|
|
79
80
|
horizontal ? "flex-row items-start gap-1" : "flex-col space-y-1",
|
|
80
81
|
className
|
|
81
82
|
),
|
|
83
|
+
"data-docubook": "card",
|
|
82
84
|
children: [
|
|
83
|
-
Icon && /* @__PURE__ */ jsx2(Icon, { className: clsx("w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5") }),
|
|
84
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex-1 min-w-0", children: [
|
|
85
|
-
/* @__PURE__ */ jsx2("div", { className: "text-base font-semibold text-foreground leading-6", children: title }),
|
|
86
|
-
/* @__PURE__ */ jsx2("div", { className: "text-sm text-muted-foreground -mt-3", children })
|
|
85
|
+
Icon && /* @__PURE__ */ jsx2(Icon, { className: clsx("dbk-card__icon", "w-5 h-5 text-primary shrink-0", horizontal && "mt-0.5"), "data-docubook": "card-icon" }),
|
|
86
|
+
/* @__PURE__ */ jsxs2("div", { className: "dbk-card__body flex-1 min-w-0", "data-docubook": "card-body", children: [
|
|
87
|
+
/* @__PURE__ */ jsx2("div", { className: "dbk-card__title text-base font-semibold text-foreground leading-6", "data-docubook": "card-title", children: title }),
|
|
88
|
+
/* @__PURE__ */ jsx2("div", { className: "dbk-card__content text-sm text-muted-foreground -mt-3", "data-docubook": "card-content", children })
|
|
87
89
|
] })
|
|
88
90
|
]
|
|
89
91
|
}
|
|
90
92
|
);
|
|
91
93
|
if (!href) return content;
|
|
92
94
|
if (LinkComponent) {
|
|
93
|
-
return /* @__PURE__ */ jsx2(LinkComponent, { href, className: "no-underline block", children: content });
|
|
95
|
+
return /* @__PURE__ */ jsx2(LinkComponent, { href, className: "dbk-card__link no-underline block", "data-docubook": "card-link", children: content });
|
|
94
96
|
}
|
|
95
|
-
return /* @__PURE__ */ jsx2("a", { className: "no-underline block", href, children: content });
|
|
97
|
+
return /* @__PURE__ */ jsx2("a", { className: "dbk-card__link no-underline block", href, "data-docubook": "card-link", children: content });
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
// src/core/components/Image.tsx
|