doccupine 0.0.134 → 0.0.136

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.
Files changed (85) hide show
  1. package/README.md +11 -9
  2. package/dist/index.js +282 -46
  3. package/dist/lib/metadata.d.ts +5 -0
  4. package/dist/lib/metadata.js +15 -4
  5. package/dist/lib/rss.d.ts +24 -0
  6. package/dist/lib/rss.js +137 -0
  7. package/dist/lib/structures.js +22 -2
  8. package/dist/templates/app/rssRoute.d.ts +11 -0
  9. package/dist/templates/app/rssRoute.js +30 -0
  10. package/dist/templates/components/Docs.d.ts +1 -1
  11. package/dist/templates/components/Docs.js +5 -2
  12. package/dist/templates/components/MDXComponents.d.ts +1 -1
  13. package/dist/templates/components/MDXComponents.js +29 -0
  14. package/dist/templates/components/SideBar.d.ts +1 -1
  15. package/dist/templates/components/SideBar.js +5 -2
  16. package/dist/templates/components/layout/ActionBar.d.ts +1 -1
  17. package/dist/templates/components/layout/ActionBar.js +44 -13
  18. package/dist/templates/components/layout/ApiPlayground.d.ts +1 -1
  19. package/dist/templates/components/layout/ApiPlayground.js +20 -28
  20. package/dist/templates/components/layout/Badge.d.ts +1 -0
  21. package/dist/templates/components/layout/Badge.js +455 -0
  22. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  23. package/dist/templates/components/layout/DocsComponents.js +5 -30
  24. package/dist/templates/components/layout/Prompt.d.ts +1 -0
  25. package/dist/templates/components/layout/Prompt.js +149 -0
  26. package/dist/templates/components/layout/Tooltip.d.ts +1 -0
  27. package/dist/templates/components/layout/Tooltip.js +222 -0
  28. package/dist/templates/components/layout/Tree.d.ts +1 -0
  29. package/dist/templates/components/layout/Tree.js +322 -0
  30. package/dist/templates/components/layout/TreeData.d.ts +1 -0
  31. package/dist/templates/components/layout/TreeData.js +131 -0
  32. package/dist/templates/components/layout/Update.d.ts +1 -1
  33. package/dist/templates/components/layout/Update.js +3 -0
  34. package/dist/templates/lib/rss.d.ts +1 -0
  35. package/dist/templates/lib/rss.js +83 -0
  36. package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
  37. package/dist/templates/mdx/accordion.mdx.js +1 -1
  38. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  39. package/dist/templates/mdx/api-playground.mdx.js +1 -1
  40. package/dist/templates/mdx/badges.mdx.d.ts +1 -0
  41. package/dist/templates/mdx/badges.mdx.js +237 -0
  42. package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
  43. package/dist/templates/mdx/buttons.mdx.js +1 -1
  44. package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
  45. package/dist/templates/mdx/callouts.mdx.js +1 -1
  46. package/dist/templates/mdx/cards.mdx.d.ts +1 -1
  47. package/dist/templates/mdx/cards.mdx.js +1 -1
  48. package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
  49. package/dist/templates/mdx/color-swatches.mdx.js +1 -1
  50. package/dist/templates/mdx/columns.mdx.d.ts +1 -1
  51. package/dist/templates/mdx/columns.mdx.js +1 -1
  52. package/dist/templates/mdx/components.mdx.d.ts +1 -1
  53. package/dist/templates/mdx/components.mdx.js +14 -2
  54. package/dist/templates/mdx/fields.mdx.d.ts +1 -1
  55. package/dist/templates/mdx/fields.mdx.js +1 -1
  56. package/dist/templates/mdx/frames.mdx.d.ts +1 -1
  57. package/dist/templates/mdx/frames.mdx.js +1 -1
  58. package/dist/templates/mdx/icons.mdx.d.ts +1 -1
  59. package/dist/templates/mdx/icons.mdx.js +1 -1
  60. package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
  61. package/dist/templates/mdx/image-and-embeds.mdx.js +1 -1
  62. package/dist/templates/mdx/images-and-embeds.mdx.d.ts +1 -0
  63. package/dist/templates/mdx/images-and-embeds.mdx.js +118 -0
  64. package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
  65. package/dist/templates/mdx/mermaid.mdx.js +1 -1
  66. package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
  67. package/dist/templates/mdx/navigation.mdx.js +5 -1
  68. package/dist/templates/mdx/prompt.mdx.d.ts +1 -0
  69. package/dist/templates/mdx/prompt.mdx.js +69 -0
  70. package/dist/templates/mdx/steps.mdx.d.ts +1 -1
  71. package/dist/templates/mdx/steps.mdx.js +1 -1
  72. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  73. package/dist/templates/mdx/tabs.mdx.js +1 -1
  74. package/dist/templates/mdx/tooltips.mdx.d.ts +1 -0
  75. package/dist/templates/mdx/tooltips.mdx.js +57 -0
  76. package/dist/templates/mdx/tree.mdx.d.ts +1 -0
  77. package/dist/templates/mdx/tree.mdx.js +158 -0
  78. package/dist/templates/mdx/update.mdx.d.ts +1 -1
  79. package/dist/templates/mdx/update.mdx.js +42 -2
  80. package/dist/templates/package.js +1 -1
  81. package/package.json +2 -2
  82. package/dist/templates/mdx/platform/external-links.mdx.d.ts +0 -1
  83. package/dist/templates/mdx/platform/external-links.mdx.js +0 -47
  84. package/dist/templates/utils/apiAnchors.d.ts +0 -1
  85. package/dist/templates/utils/apiAnchors.js +0 -39
@@ -0,0 +1,322 @@
1
+ export const treeTemplate = `"use client";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import styled, { css } from "styled-components";
4
+ import { Theme } from "@/app/theme";
5
+ import { Icon } from "@/components/layout/Icon";
6
+ import { thinScrollbar } from "@/components/layout/SharedStyled";
7
+ import type { TreeNode } from "@/components/layout/TreeData";
8
+
9
+ const TYPE_AHEAD_RESET_MS = 600;
10
+
11
+ interface FlatItem {
12
+ node: TreeNode;
13
+ parentId: string | null;
14
+ }
15
+
16
+ // The prose container styles every descendant "ul li" (bullet dots, padding,
17
+ // min-height) at (0,1,2)+ specificity, so the tree's own lists and items use
18
+ // && to reach (0,2,0) and win.
19
+ const StyledTree = styled.ul<{ theme: Theme }>\`
20
+ && {
21
+ background: \${({ theme }) => theme.colors.light};
22
+ border: solid 1px \${({ theme }) => theme.colors.grayLight};
23
+ border-radius: \${({ theme }) => theme.spacing.radius.lg};
24
+ padding: 12px;
25
+ margin: 0;
26
+ width: 100%;
27
+ list-style: none;
28
+ overflow-x: auto;
29
+ \${thinScrollbar};
30
+ }
31
+ \`;
32
+
33
+ const StyledTreeGroup = styled.ul<{ theme: Theme }>\`
34
+ && {
35
+ list-style: none;
36
+ margin: 0 0 0 13px;
37
+ padding: 0 0 0 9px;
38
+ border-left: solid 1px \${({ theme }) => theme.colors.grayLight};
39
+ }
40
+ \`;
41
+
42
+ const StyledTreeRow = styled.span<{ theme: Theme; $isInteractive: boolean }>\`
43
+ display: flex;
44
+ align-items: center;
45
+ gap: 6px;
46
+ padding: 4px 6px;
47
+ border-radius: \${({ theme }) => theme.spacing.radius.xs};
48
+ transition: background 0.2s ease;
49
+
50
+ \${({ $isInteractive, theme }) =>
51
+ $isInteractive &&
52
+ css\`
53
+ cursor: pointer;
54
+
55
+ &:hover {
56
+ background: \${theme.colors.grayLight};
57
+ }
58
+ \`}
59
+ \`;
60
+
61
+ const StyledTreeItem = styled.li<{ theme: Theme }>\`
62
+ && {
63
+ display: block;
64
+ padding: 0;
65
+ margin: 0;
66
+ min-height: 0;
67
+ outline: none;
68
+ }
69
+
70
+ &&::before {
71
+ content: none;
72
+ }
73
+
74
+ &:focus-visible > \${StyledTreeRow} {
75
+ box-shadow: 0 0 0 2px \${({ theme }) => theme.colors.primaryLight};
76
+ }
77
+ \`;
78
+
79
+ const StyledTreeChevron = styled.span<{ theme: Theme; $isOpen: boolean }>\`
80
+ display: inline-flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ flex-shrink: 0;
84
+ width: 16px;
85
+ height: 16px;
86
+ color: \${({ theme }) => theme.colors.gray};
87
+ transition: transform 0.2s ease;
88
+
89
+ \${({ $isOpen }) =>
90
+ $isOpen &&
91
+ css\`
92
+ transform: rotate(90deg);
93
+ \`}
94
+ \`;
95
+
96
+ const StyledTreeSpacer = styled.span\`
97
+ flex-shrink: 0;
98
+ width: 16px;
99
+ height: 16px;
100
+ \`;
101
+
102
+ const StyledTreeIcon = styled.span<{ theme: Theme }>\`
103
+ display: inline-flex;
104
+ align-items: center;
105
+ justify-content: center;
106
+ flex-shrink: 0;
107
+ color: \${({ theme }) => theme.colors.gray};
108
+ \`;
109
+
110
+ const StyledTreeName = styled.span<{ theme: Theme; $isFolder: boolean }>\`
111
+ font-family: \${({ theme }) => theme.fonts.mono};
112
+ font-size: 14px;
113
+ line-height: 1.6;
114
+ white-space: nowrap;
115
+ color: \${({ theme, $isFolder }) =>
116
+ $isFolder ? theme.colors.dark : theme.colors.grayDark};
117
+ \`;
118
+
119
+ interface TreeProps {
120
+ nodes: TreeNode[];
121
+ }
122
+
123
+ // Renders the TreeNode data that the Tree compound in MDXComponents parses
124
+ // out of either authoring syntax. Receiving plain data (never elements)
125
+ // keeps the server/client boundary trivially serializable.
126
+ function Tree({ nodes }: TreeProps) {
127
+ // Open state is stored as overrides on top of each folder's defaultOpen so
128
+ // nodes parsed after a re-render keep their authored state until toggled.
129
+ const [overrides, setOverrides] = useState<Record<string, boolean>>({});
130
+ const [focusedId, setFocusedId] = useState<string | null>(null);
131
+ const itemRefs = useRef<Map<string, HTMLLIElement>>(new Map());
132
+ const typeAheadBuffer = useRef("");
133
+ const typeAheadTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
134
+
135
+ useEffect(
136
+ () => () => {
137
+ if (typeAheadTimer.current) clearTimeout(typeAheadTimer.current);
138
+ },
139
+ [],
140
+ );
141
+
142
+ const isOpen = useCallback(
143
+ (node: TreeNode) => overrides[node.id] ?? node.defaultOpen,
144
+ [overrides],
145
+ );
146
+
147
+ // The flattened list of currently visible items drives keyboard
148
+ // navigation in document order.
149
+ const visible = useMemo(() => {
150
+ const out: FlatItem[] = [];
151
+ const walk = (list: TreeNode[], parentId: string | null) => {
152
+ list.forEach((node) => {
153
+ out.push({ node, parentId });
154
+ if (node.isFolder && isOpen(node)) {
155
+ walk(node.children, node.id);
156
+ }
157
+ });
158
+ };
159
+ walk(nodes, null);
160
+ return out;
161
+ }, [nodes, isOpen]);
162
+
163
+ // Roving tabindex: exactly one visible item is tabbable. Falls back to the
164
+ // first item when focus points at a node hidden by a collapsed ancestor.
165
+ const activeId = useMemo(() => {
166
+ if (focusedId && visible.some((item) => item.node.id === focusedId)) {
167
+ return focusedId;
168
+ }
169
+ return visible.length > 0 ? visible[0].node.id : null;
170
+ }, [focusedId, visible]);
171
+
172
+ const setOpen = (node: TreeNode, open: boolean) => {
173
+ if (!node.isFolder || !node.openable) return;
174
+ setOverrides((prev) => ({ ...prev, [node.id]: open }));
175
+ };
176
+
177
+ const focusItem = (id: string) => {
178
+ setFocusedId(id);
179
+ itemRefs.current.get(id)?.focus();
180
+ };
181
+
182
+ const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>) => {
183
+ if (event.ctrlKey || event.metaKey || event.altKey) return;
184
+ const index = visible.findIndex((item) => item.node.id === activeId);
185
+ if (index < 0) return;
186
+ const current = visible[index];
187
+ const node = current.node;
188
+ const key = event.key;
189
+
190
+ if (key === "ArrowDown") {
191
+ event.preventDefault();
192
+ if (index + 1 < visible.length) focusItem(visible[index + 1].node.id);
193
+ } else if (key === "ArrowUp") {
194
+ event.preventDefault();
195
+ if (index > 0) focusItem(visible[index - 1].node.id);
196
+ } else if (key === "ArrowRight") {
197
+ event.preventDefault();
198
+ if (!node.isFolder) return;
199
+ if (!isOpen(node)) setOpen(node, true);
200
+ else if (node.children.length > 0) focusItem(node.children[0].id);
201
+ } else if (key === "ArrowLeft") {
202
+ event.preventDefault();
203
+ if (node.isFolder && isOpen(node) && node.openable) {
204
+ setOpen(node, false);
205
+ } else if (current.parentId) {
206
+ focusItem(current.parentId);
207
+ }
208
+ } else if (key === "Home") {
209
+ event.preventDefault();
210
+ focusItem(visible[0].node.id);
211
+ } else if (key === "End") {
212
+ event.preventDefault();
213
+ focusItem(visible[visible.length - 1].node.id);
214
+ } else if (key === "Enter" || key === " ") {
215
+ event.preventDefault();
216
+ setOpen(node, !isOpen(node));
217
+ } else if (key === "*") {
218
+ event.preventDefault();
219
+ setOverrides((prev) => {
220
+ const next = { ...prev };
221
+ visible.forEach((item) => {
222
+ if (
223
+ item.parentId === current.parentId &&
224
+ item.node.isFolder &&
225
+ item.node.openable
226
+ ) {
227
+ next[item.node.id] = true;
228
+ }
229
+ });
230
+ return next;
231
+ });
232
+ } else if (key.length === 1 && key !== " ") {
233
+ // Type-ahead: buffered characters jump to the next item whose name
234
+ // starts with what was typed.
235
+ if (typeAheadTimer.current) clearTimeout(typeAheadTimer.current);
236
+ typeAheadBuffer.current += key.toLowerCase();
237
+ typeAheadTimer.current = setTimeout(() => {
238
+ typeAheadBuffer.current = "";
239
+ }, TYPE_AHEAD_RESET_MS);
240
+ const query = typeAheadBuffer.current;
241
+ const start = query.length === 1 ? index + 1 : index;
242
+ for (let offset = 0; offset < visible.length; offset++) {
243
+ const item = visible[(start + offset) % visible.length];
244
+ if (item.node.name.toLowerCase().startsWith(query)) {
245
+ focusItem(item.node.id);
246
+ break;
247
+ }
248
+ }
249
+ }
250
+ };
251
+
252
+ const renderItems = (list: TreeNode[], level: number) =>
253
+ list.map((node, index) => {
254
+ const open = node.isFolder && isOpen(node);
255
+ const isInteractive = node.isFolder && node.openable;
256
+ return (
257
+ <StyledTreeItem
258
+ key={node.id}
259
+ role="treeitem"
260
+ aria-level={level}
261
+ aria-setsize={list.length}
262
+ aria-posinset={index + 1}
263
+ aria-expanded={node.isFolder ? open : undefined}
264
+ tabIndex={node.id === activeId ? 0 : -1}
265
+ ref={(element) => {
266
+ if (element) itemRefs.current.set(node.id, element);
267
+ else itemRefs.current.delete(node.id);
268
+ }}
269
+ onFocus={(event) => {
270
+ // Focus events bubble through nested treeitems; without this a
271
+ // child's focus would also mark every ancestor as focused.
272
+ event.stopPropagation();
273
+ setFocusedId(node.id);
274
+ }}
275
+ >
276
+ {/* Safari does not reliably focus the item on click, so focus is
277
+ set explicitly before toggling. */}
278
+ <StyledTreeRow
279
+ $isInteractive={isInteractive}
280
+ onClick={(event) => {
281
+ event.stopPropagation();
282
+ focusItem(node.id);
283
+ if (isInteractive) setOpen(node, !open);
284
+ }}
285
+ >
286
+ {isInteractive ? (
287
+ <StyledTreeChevron $isOpen={open} aria-hidden>
288
+ <Icon name="ChevronRight" size={14} />
289
+ </StyledTreeChevron>
290
+ ) : (
291
+ <StyledTreeSpacer aria-hidden />
292
+ )}
293
+ <StyledTreeIcon aria-hidden>
294
+ <Icon
295
+ name={node.isFolder ? (open ? "FolderOpen" : "Folder") : "File"}
296
+ size={16}
297
+ />
298
+ </StyledTreeIcon>
299
+ <StyledTreeName $isFolder={node.isFolder}>
300
+ {node.name}
301
+ </StyledTreeName>
302
+ </StyledTreeRow>
303
+ {node.isFolder && open && node.children.length > 0 && (
304
+ <StyledTreeGroup role="group">
305
+ {renderItems(node.children, level + 1)}
306
+ </StyledTreeGroup>
307
+ )}
308
+ </StyledTreeItem>
309
+ );
310
+ });
311
+
312
+ if (nodes.length === 0) return null;
313
+
314
+ return (
315
+ <StyledTree role="tree" aria-label="File tree" onKeyDown={handleKeyDown}>
316
+ {renderItems(nodes, 1)}
317
+ </StyledTree>
318
+ );
319
+ }
320
+
321
+ export { Tree };
322
+ `;
@@ -0,0 +1 @@
1
+ export declare const treeDataTemplate = "import React from \"react\";\n\nexport interface TreeNode {\n id: string;\n name: string;\n isFolder: boolean;\n defaultOpen: boolean;\n openable: boolean;\n children: TreeNode[];\n}\n\nexport interface TreeFolderProps {\n name: string;\n defaultOpen?: boolean;\n openable?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface TreeFileProps {\n name: string;\n}\n\n// Tree.Folder and Tree.File are declarative markers: the Tree compound in\n// MDXComponents parses them into TreeNode data before anything renders, so\n// they never render on their own. This module must stay free of\n// \"use client\" - parsing runs where MDX creates the elements (server\n// components included), and only there is comparing an element's type\n// against these markers guaranteed to work. Client modules would turn the\n// markers into reference proxies whose identity does not survive the\n// server boundary.\nexport function TreeFolder(_props: TreeFolderProps) {\n return null;\n}\n\nexport function TreeFile(_props: TreeFileProps) {\n return null;\n}\n\nfunction extractText(children: React.ReactNode): string {\n if (children == null || typeof children === \"boolean\") return \"\";\n if (typeof children === \"string\" || typeof children === \"number\") {\n return String(children);\n }\n if (Array.isArray(children)) return children.map(extractText).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractText(element.props.children);\n }\n return \"\";\n}\n\ntype ListElement = React.ReactElement<{ children?: React.ReactNode }>;\n\nfunction isListElement(child: React.ReactNode): child is ListElement {\n return (\n React.isValidElement(child) && (child.type === \"ul\" || child.type === \"ol\")\n );\n}\n\n// Markdown list syntax: a trailing slash or nested items mark a folder, and\n// folders that contain items expand by default. Names strip inline\n// formatting because only the text content is extracted. Ids derive from\n// position and name so open state survives re-renders.\nfunction parseListItems(list: ListElement, parentId: string): TreeNode[] {\n const nodes: TreeNode[] = [];\n React.Children.forEach(list.props.children, (item) => {\n if (!React.isValidElement(item) || item.type !== \"li\") return;\n const li = item as React.ReactElement<{ children?: React.ReactNode }>;\n const labelParts: React.ReactNode[] = [];\n const nestedLists: ListElement[] = [];\n React.Children.forEach(li.props.children, (child) => {\n if (isListElement(child)) nestedLists.push(child);\n else labelParts.push(child);\n });\n const raw = extractText(labelParts).trim();\n const name = raw.endsWith(\"/\") ? raw.slice(0, -1) : raw;\n if (!name) return;\n const id = parentId + \"/\" + nodes.length + \"-\" + name;\n nodes.push({\n id,\n name,\n isFolder: raw.endsWith(\"/\") || nestedLists.length > 0,\n defaultOpen: nestedLists.length > 0,\n openable: true,\n children: nestedLists.flatMap((nested) => parseListItems(nested, id)),\n });\n });\n return nodes;\n}\n\n// Both authoring syntaxes (Tree.Folder/Tree.File elements and markdown\n// lists) normalize into the same node model, so they can be mixed freely.\nexport function parseTreeChildren(\n children: React.ReactNode,\n parentId: string,\n): TreeNode[] {\n const nodes: TreeNode[] = [];\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) return;\n if (child.type === TreeFolder) {\n const props = child.props as TreeFolderProps;\n if (!props.name) return;\n const id = parentId + \"/\" + nodes.length + \"-\" + props.name;\n nodes.push({\n id,\n name: props.name,\n isFolder: true,\n defaultOpen: props.defaultOpen === true,\n openable: props.openable !== false,\n children: parseTreeChildren(props.children, id),\n });\n } else if (child.type === TreeFile) {\n const props = child.props as TreeFileProps;\n if (!props.name) return;\n nodes.push({\n id: parentId + \"/\" + nodes.length + \"-\" + props.name,\n name: props.name,\n isFolder: false,\n defaultOpen: false,\n openable: false,\n children: [],\n });\n } else if (isListElement(child)) {\n nodes.push(...parseListItems(child, parentId + \"/\" + nodes.length));\n }\n });\n return nodes;\n}\n";
@@ -0,0 +1,131 @@
1
+ export const treeDataTemplate = `import React from "react";
2
+
3
+ export interface TreeNode {
4
+ id: string;
5
+ name: string;
6
+ isFolder: boolean;
7
+ defaultOpen: boolean;
8
+ openable: boolean;
9
+ children: TreeNode[];
10
+ }
11
+
12
+ export interface TreeFolderProps {
13
+ name: string;
14
+ defaultOpen?: boolean;
15
+ openable?: boolean;
16
+ children?: React.ReactNode;
17
+ }
18
+
19
+ export interface TreeFileProps {
20
+ name: string;
21
+ }
22
+
23
+ // Tree.Folder and Tree.File are declarative markers: the Tree compound in
24
+ // MDXComponents parses them into TreeNode data before anything renders, so
25
+ // they never render on their own. This module must stay free of
26
+ // "use client" - parsing runs where MDX creates the elements (server
27
+ // components included), and only there is comparing an element's type
28
+ // against these markers guaranteed to work. Client modules would turn the
29
+ // markers into reference proxies whose identity does not survive the
30
+ // server boundary.
31
+ export function TreeFolder(_props: TreeFolderProps) {
32
+ return null;
33
+ }
34
+
35
+ export function TreeFile(_props: TreeFileProps) {
36
+ return null;
37
+ }
38
+
39
+ function extractText(children: React.ReactNode): string {
40
+ if (children == null || typeof children === "boolean") return "";
41
+ if (typeof children === "string" || typeof children === "number") {
42
+ return String(children);
43
+ }
44
+ if (Array.isArray(children)) return children.map(extractText).join("");
45
+ if (React.isValidElement(children)) {
46
+ const element = children as React.ReactElement<{
47
+ children?: React.ReactNode;
48
+ }>;
49
+ return extractText(element.props.children);
50
+ }
51
+ return "";
52
+ }
53
+
54
+ type ListElement = React.ReactElement<{ children?: React.ReactNode }>;
55
+
56
+ function isListElement(child: React.ReactNode): child is ListElement {
57
+ return (
58
+ React.isValidElement(child) && (child.type === "ul" || child.type === "ol")
59
+ );
60
+ }
61
+
62
+ // Markdown list syntax: a trailing slash or nested items mark a folder, and
63
+ // folders that contain items expand by default. Names strip inline
64
+ // formatting because only the text content is extracted. Ids derive from
65
+ // position and name so open state survives re-renders.
66
+ function parseListItems(list: ListElement, parentId: string): TreeNode[] {
67
+ const nodes: TreeNode[] = [];
68
+ React.Children.forEach(list.props.children, (item) => {
69
+ if (!React.isValidElement(item) || item.type !== "li") return;
70
+ const li = item as React.ReactElement<{ children?: React.ReactNode }>;
71
+ const labelParts: React.ReactNode[] = [];
72
+ const nestedLists: ListElement[] = [];
73
+ React.Children.forEach(li.props.children, (child) => {
74
+ if (isListElement(child)) nestedLists.push(child);
75
+ else labelParts.push(child);
76
+ });
77
+ const raw = extractText(labelParts).trim();
78
+ const name = raw.endsWith("/") ? raw.slice(0, -1) : raw;
79
+ if (!name) return;
80
+ const id = parentId + "/" + nodes.length + "-" + name;
81
+ nodes.push({
82
+ id,
83
+ name,
84
+ isFolder: raw.endsWith("/") || nestedLists.length > 0,
85
+ defaultOpen: nestedLists.length > 0,
86
+ openable: true,
87
+ children: nestedLists.flatMap((nested) => parseListItems(nested, id)),
88
+ });
89
+ });
90
+ return nodes;
91
+ }
92
+
93
+ // Both authoring syntaxes (Tree.Folder/Tree.File elements and markdown
94
+ // lists) normalize into the same node model, so they can be mixed freely.
95
+ export function parseTreeChildren(
96
+ children: React.ReactNode,
97
+ parentId: string,
98
+ ): TreeNode[] {
99
+ const nodes: TreeNode[] = [];
100
+ React.Children.forEach(children, (child) => {
101
+ if (!React.isValidElement(child)) return;
102
+ if (child.type === TreeFolder) {
103
+ const props = child.props as TreeFolderProps;
104
+ if (!props.name) return;
105
+ const id = parentId + "/" + nodes.length + "-" + props.name;
106
+ nodes.push({
107
+ id,
108
+ name: props.name,
109
+ isFolder: true,
110
+ defaultOpen: props.defaultOpen === true,
111
+ openable: props.openable !== false,
112
+ children: parseTreeChildren(props.children, id),
113
+ });
114
+ } else if (child.type === TreeFile) {
115
+ const props = child.props as TreeFileProps;
116
+ if (!props.name) return;
117
+ nodes.push({
118
+ id: parentId + "/" + nodes.length + "-" + props.name,
119
+ name: props.name,
120
+ isFolder: false,
121
+ defaultOpen: false,
122
+ openable: false,
123
+ children: [],
124
+ });
125
+ } else if (isListElement(child)) {
126
+ nodes.push(...parseListItems(child, parentId + "/" + nodes.length));
127
+ }
128
+ });
129
+ return nodes;
130
+ }
131
+ `;
@@ -1 +1 @@
1
- export declare const updateTemplate = "\"use client\";\nimport styled from \"styled-components\";\nimport { styledSmall } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\nimport { slugify } from \"@/components/layout/Slug\";\n\nconst StyledUpdate = styled.div<{ theme: Theme; $columns?: number }>`\n position: relative;\n display: flex;\n gap: 20px;\n flex-direction: column;\n\n ${mq(\"lg\")} {\n margin: 20px 0;\n flex-direction: row;\n }\n`;\n\nconst StyledUpdateLabel = styled.a<{ theme: Theme }>`\n display: inline-block;\n width: fit-content;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.primary};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n font-weight: 600;\n text-decoration: none;\n ${({ theme }) => styledSmall(theme)};\n\n &:hover {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 35%, transparent)`};\n }\n`;\n\nconst StyledUpdateDescription = styled.div<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.gray};\n`;\n\nconst StyledUpdateSidebar = styled.div`\n display: flex;\n flex-direction: column;\n gap: 10px;\n\n ${mq(\"lg\")} {\n position: sticky;\n top: 80px;\n align-self: flex-start;\n min-width: 160px;\n }\n`;\n\nconst StyledUpdateChildren = styled.div<{ theme: Theme }>`\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 20px;\n color: ${({ theme }) => theme.colors.gray};\n`;\n\ninterface UpdateProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n label: string;\n description?: string;\n}\n\nfunction Update({ children, label = \"Label\", description, id }: UpdateProps) {\n // MDXComponents injects a de-duplicated id from the shared slugger so the\n // index sidebar anchor resolves here; fall back to a plain slug when used\n // outside the MDX pipeline. The label doubles as an anchor so readers can\n // right-click to copy the deep link (native #anchor jump is offset by the\n // global scroll-padding-top).\n const anchor = id ?? slugify(label);\n return (\n <StyledUpdate id={anchor}>\n <StyledUpdateSidebar>\n <div>\n <StyledUpdateLabel href={`#${anchor}`}>{label}</StyledUpdateLabel>\n </div>\n {description && (\n <StyledUpdateDescription>{description}</StyledUpdateDescription>\n )}\n </StyledUpdateSidebar>\n <StyledUpdateChildren>{children}</StyledUpdateChildren>\n </StyledUpdate>\n );\n}\n\nexport { Update };\n";
1
+ export declare const updateTemplate = "\"use client\";\nimport styled from \"styled-components\";\nimport { styledSmall } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\nimport { slugify } from \"@/components/layout/Slug\";\n\nconst StyledUpdate = styled.div<{ theme: Theme; $columns?: number }>`\n position: relative;\n display: flex;\n gap: 20px;\n flex-direction: column;\n\n ${mq(\"lg\")} {\n margin: 20px 0;\n flex-direction: row;\n }\n`;\n\nconst StyledUpdateLabel = styled.a<{ theme: Theme }>`\n display: inline-block;\n width: fit-content;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.primary};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n font-weight: 600;\n text-decoration: none;\n ${({ theme }) => styledSmall(theme)};\n\n &:hover {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 35%, transparent)`};\n }\n`;\n\nconst StyledUpdateDescription = styled.div<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.gray};\n`;\n\nconst StyledUpdateSidebar = styled.div`\n display: flex;\n flex-direction: column;\n gap: 10px;\n\n ${mq(\"lg\")} {\n position: sticky;\n top: 80px;\n align-self: flex-start;\n min-width: 160px;\n }\n`;\n\nconst StyledUpdateChildren = styled.div<{ theme: Theme }>`\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 20px;\n color: ${({ theme }) => theme.colors.gray};\n`;\n\ninterface UpdateProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n label: string;\n description?: string;\n // Alternative pure-Markdown text for this entry in the page's RSS feed.\n // Consumed at generation time; never rendered on the page.\n rss?: string;\n}\n\nfunction Update({ children, label = \"Label\", description, id }: UpdateProps) {\n // MDXComponents injects a de-duplicated id from the shared slugger so the\n // index sidebar anchor resolves here; fall back to a plain slug when used\n // outside the MDX pipeline. The label doubles as an anchor so readers can\n // right-click to copy the deep link (native #anchor jump is offset by the\n // global scroll-padding-top).\n const anchor = id ?? slugify(label);\n return (\n <StyledUpdate id={anchor}>\n <StyledUpdateSidebar>\n <div>\n <StyledUpdateLabel href={`#${anchor}`}>{label}</StyledUpdateLabel>\n </div>\n {description && (\n <StyledUpdateDescription>{description}</StyledUpdateDescription>\n )}\n </StyledUpdateSidebar>\n <StyledUpdateChildren>{children}</StyledUpdateChildren>\n </StyledUpdate>\n );\n}\n\nexport { Update };\n";
@@ -64,6 +64,9 @@ interface UpdateProps extends React.HTMLAttributes<HTMLDivElement> {
64
64
  children: React.ReactNode;
65
65
  label: string;
66
66
  description?: string;
67
+ // Alternative pure-Markdown text for this entry in the page's RSS feed.
68
+ // Consumed at generation time; never rendered on the page.
69
+ rss?: string;
67
70
  }
68
71
 
69
72
  function Update({ children, label = "Label", description, id }: UpdateProps) {
@@ -0,0 +1 @@
1
+ export declare const rssLibTemplate = "import { config } from \"@/utils/config\";\n\nexport interface RssItem {\n title: string;\n anchor: string;\n description: string;\n}\n\nexport interface RssFeedData {\n // Page path relative to the site root, e.g. \"update\" or \"guides/setup\".\n // Empty string means the homepage feed (served from /rss.xml).\n pagePath: string;\n // Channel title; null falls back to the site name from config.json.\n title: string | null;\n // Channel description; null falls back to the config.json description.\n description: string | null;\n items: RssItem[];\n}\n\n// Same base-URL resolution as sitemap.ts/robots.ts: env override first, then\n// config.json. Without either, feed links degrade to root-relative paths.\nfunction resolveBaseUrl(): string | null {\n const raw = process.env.NEXT_PUBLIC_SITE_URL ?? config.url;\n if (!raw) return null;\n return raw.replace(/\\/$/, \"\");\n}\n\n// Ampersand first, or it would re-escape the other entities.\nfunction escapeXml(text: string): string {\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\");\n}\n\n// Builds the RSS 2.0 document for a page's subscribable changelog. Entry\n// descriptions arrive as pure Markdown (components, code, and HTML were\n// removed at generation time) and are entity-escaped here, so no CDATA\n// sections are needed. Entries carry no pubDate: the guid is the entry's\n// permalink, so feed readers surface new entries when new guids appear.\nexport function buildRssFeed(feed: RssFeedData): string {\n const base = resolveBaseUrl() ?? \"\";\n // The homepage feed has an empty pagePath; joining through this prefix\n // keeps its URLs free of double slashes (\"//rss.xml\" would be read as a\n // protocol-relative URL).\n const pagePrefix = feed.pagePath ? `/${feed.pagePath}` : \"\";\n const pageUrl = `${base}${pagePrefix}` || \"/\";\n const feedUrl = `${base}${pagePrefix}/rss.xml`;\n const siteName = config.name || \"Documentation\";\n const title = feed.title ?? siteName;\n const description = feed.description ?? config.description ?? title;\n\n const items = feed.items.map((item) => {\n const link = `${pageUrl}#${item.anchor}`;\n return [\n \" <item>\",\n ` <title>${escapeXml(item.title)}</title>`,\n ` <link>${escapeXml(link)}</link>`,\n ` <guid isPermaLink=\"true\">${escapeXml(link)}</guid>`,\n ` <description>${escapeXml(item.description)}</description>`,\n \" </item>\",\n ].join(\"\\n\");\n });\n\n return [\n `<?xml version=\"1.0\" encoding=\"UTF-8\"?>`,\n `<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">`,\n \" <channel>\",\n ` <title>${escapeXml(title)}</title>`,\n ` <link>${escapeXml(pageUrl)}</link>`,\n ` <description>${escapeXml(description)}</description>`,\n ` <atom:link href=\"${escapeXml(feedUrl)}\" rel=\"self\" type=\"application/rss+xml\" />`,\n ` <lastBuildDate>${new Date().toUTCString()}</lastBuildDate>`,\n ` <copyright>${escapeXml(siteName)}</copyright>`,\n ...items,\n \" </channel>\",\n \"</rss>\",\n \"\",\n ].join(\"\\n\");\n}\n";
@@ -0,0 +1,83 @@
1
+ export const rssLibTemplate = `import { config } from "@/utils/config";
2
+
3
+ export interface RssItem {
4
+ title: string;
5
+ anchor: string;
6
+ description: string;
7
+ }
8
+
9
+ export interface RssFeedData {
10
+ // Page path relative to the site root, e.g. "update" or "guides/setup".
11
+ // Empty string means the homepage feed (served from /rss.xml).
12
+ pagePath: string;
13
+ // Channel title; null falls back to the site name from config.json.
14
+ title: string | null;
15
+ // Channel description; null falls back to the config.json description.
16
+ description: string | null;
17
+ items: RssItem[];
18
+ }
19
+
20
+ // Same base-URL resolution as sitemap.ts/robots.ts: env override first, then
21
+ // config.json. Without either, feed links degrade to root-relative paths.
22
+ function resolveBaseUrl(): string | null {
23
+ const raw = process.env.NEXT_PUBLIC_SITE_URL ?? config.url;
24
+ if (!raw) return null;
25
+ return raw.replace(/\\/$/, "");
26
+ }
27
+
28
+ // Ampersand first, or it would re-escape the other entities.
29
+ function escapeXml(text: string): string {
30
+ return text
31
+ .replace(/&/g, "&amp;")
32
+ .replace(/</g, "&lt;")
33
+ .replace(/>/g, "&gt;")
34
+ .replace(/"/g, "&quot;")
35
+ .replace(/'/g, "&apos;");
36
+ }
37
+
38
+ // Builds the RSS 2.0 document for a page's subscribable changelog. Entry
39
+ // descriptions arrive as pure Markdown (components, code, and HTML were
40
+ // removed at generation time) and are entity-escaped here, so no CDATA
41
+ // sections are needed. Entries carry no pubDate: the guid is the entry's
42
+ // permalink, so feed readers surface new entries when new guids appear.
43
+ export function buildRssFeed(feed: RssFeedData): string {
44
+ const base = resolveBaseUrl() ?? "";
45
+ // The homepage feed has an empty pagePath; joining through this prefix
46
+ // keeps its URLs free of double slashes ("//rss.xml" would be read as a
47
+ // protocol-relative URL).
48
+ const pagePrefix = feed.pagePath ? \`/\${feed.pagePath}\` : "";
49
+ const pageUrl = \`\${base}\${pagePrefix}\` || "/";
50
+ const feedUrl = \`\${base}\${pagePrefix}/rss.xml\`;
51
+ const siteName = config.name || "Documentation";
52
+ const title = feed.title ?? siteName;
53
+ const description = feed.description ?? config.description ?? title;
54
+
55
+ const items = feed.items.map((item) => {
56
+ const link = \`\${pageUrl}#\${item.anchor}\`;
57
+ return [
58
+ " <item>",
59
+ \` <title>\${escapeXml(item.title)}</title>\`,
60
+ \` <link>\${escapeXml(link)}</link>\`,
61
+ \` <guid isPermaLink="true">\${escapeXml(link)}</guid>\`,
62
+ \` <description>\${escapeXml(item.description)}</description>\`,
63
+ " </item>",
64
+ ].join("\\n");
65
+ });
66
+
67
+ return [
68
+ \`<?xml version="1.0" encoding="UTF-8"?>\`,
69
+ \`<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">\`,
70
+ " <channel>",
71
+ \` <title>\${escapeXml(title)}</title>\`,
72
+ \` <link>\${escapeXml(pageUrl)}</link>\`,
73
+ \` <description>\${escapeXml(description)}</description>\`,
74
+ \` <atom:link href="\${escapeXml(feedUrl)}" rel="self" type="application/rss+xml" />\`,
75
+ \` <lastBuildDate>\${new Date().toUTCString()}</lastBuildDate>\`,
76
+ \` <copyright>\${escapeXml(siteName)}</copyright>\`,
77
+ ...items,
78
+ " </channel>",
79
+ "</rss>",
80
+ "",
81
+ ].join("\\n");
82
+ }
83
+ `;
@@ -1 +1 @@
1
- export declare const accordionMdxTemplate = "---\ntitle: \"Accordion\"\ndescription: \"Interactive panels for toggling visibility of content.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 5\n---\n# Accordion\n\nInteractive panels for toggling visibility of content.\n\nAccordion elements help organize information by letting users show or hide sections as needed. They\u2019re an effective way to manage progressive disclosure and simplify navigation through dense or optional content.\n\n## Accordion Usage\n\nYou can use the Accordion component directly within your MDX files without any import. The following example shows a basic usage:\n\n````html\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>\n````\n\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>\n\n## Open by default\n\nPass `defaultOpen` to have the panel expanded on first render instead of collapsed:\n\n````html\n<Accordion title=\"Read me first\" defaultOpen>\n This panel starts expanded.\n</Accordion>\n````\n\n<Accordion title=\"Read me first\" defaultOpen>\n This panel starts expanded.\n</Accordion>\n\n## Properties\n\n<Field value=\"title\" type=\"string\" required>\n The title of the accordion.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the accordion.\n</Field>\n\n<Field value=\"defaultOpen\" type=\"boolean\">\n Whether the panel is expanded on first render. Defaults to `false`.\n</Field>";
1
+ export declare const accordionMdxTemplate = "---\ntitle: \"Accordion\"\ndescription: \"Interactive panels for toggling visibility of content.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 6\n---\n# Accordion\n\nInteractive panels for toggling visibility of content.\n\nAccordion elements help organize information by letting users show or hide sections as needed. They\u2019re an effective way to manage progressive disclosure and simplify navigation through dense or optional content.\n\n## Accordion Usage\n\nYou can use the Accordion component directly within your MDX files without any import. The following example shows a basic usage:\n\n````html\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>\n````\n\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>\n\n## Open by default\n\nPass `defaultOpen` to have the panel expanded on first render instead of collapsed:\n\n````html\n<Accordion title=\"Read me first\" defaultOpen>\n This panel starts expanded.\n</Accordion>\n````\n\n<Accordion title=\"Read me first\" defaultOpen>\n This panel starts expanded.\n</Accordion>\n\n## Properties\n\n<Field value=\"title\" type=\"string\" required>\n The title of the accordion.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the accordion.\n</Field>\n\n<Field value=\"defaultOpen\" type=\"boolean\">\n Whether the panel is expanded on first render. Defaults to `false`.\n</Field>";
@@ -4,7 +4,7 @@ description: "Interactive panels for toggling visibility of content."
4
4
  date: "2026-02-19"
5
5
  category: "Components"
6
6
  categoryOrder: 1
7
- order: 5
7
+ order: 6
8
8
  ---
9
9
  # Accordion
10
10
 
@@ -1 +1 @@
1
- export declare const apiPlaygroundMdxTemplate = "---\ntitle: \"API Playground\"\ndescription: \"Turn an OpenAPI document into an interactive API reference where readers send real requests and see live responses, right inside your docs.\"\ndate: \"2026-07-25\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 15\n---\n# API Playground\n\nPoint Doccupine at an OpenAPI document and it generates a complete, interactive API reference: one page per endpoint, grouped by tag in the sidebar, each with a \"Send request\" panel that makes real calls and shows the live response - plus copy-pasteable code snippets.\n\n<Callout type=\"note\">\nThe playground is driven entirely by your OpenAPI document. There is nothing to wire up by hand - add one line of config and every endpoint becomes a documented, runnable page.\n</Callout>\n\n## Try it\n\nPress **Try it** below to open the playground, tweak the request body, and send a real request to a live API - right from these docs.\n\n<ApiPlaygroundDemo />\n\n## Enabling the playground\n\n<Steps>\n <Step title=\"Add an openapi path to doccupine.json.\">\n Point at a local `.json`, `.yaml`, or `.yml` OpenAPI 3.0 or 3.1 document.\n\n```json\n{\n \"watchDir\": \"docs\",\n \"outputDir\": \"nextjs-app\",\n \"openapi\": \"openapi.yaml\"\n}\n```\n </Step>\n <Step title=\"Run Doccupine.\">\n On the next build (or live, while watching) Doccupine parses the document, resolves every `$ref`, and writes an endpoint page for each operation.\n </Step>\n <Step title=\"Open the API Reference section.\">\n Endpoints appear in the sidebar grouped by their OpenAPI tag. Editing the spec regenerates the pages automatically.\n </Step>\n</Steps>\n\n## Example spec\n\nDo not have a document yet? This `openapi.yaml` points at [JSONPlaceholder](https://jsonplaceholder.typicode.com), a free public test API, so it works end to end - save it, set `openapi` to it, and the generated pages can send real requests:\n\n```yaml\nopenapi: 3.1.0\ninfo:\n title: JSONPlaceholder\n version: 1.0.0\nservers:\n - url: https://jsonplaceholder.typicode.com\ntags:\n - name: Todos\n - name: Posts\npaths:\n /todos/{id}:\n get:\n summary: Get a to-do\n tags: [Todos]\n parameters:\n - name: id\n in: path\n required: true\n schema:\n type: integer\n responses:\n \"200\":\n description: Just a demo of a to-do item\n /posts:\n post:\n summary: Create a post\n tags: [Posts]\n requestBody:\n required: true\n content:\n application/json:\n example:\n title: Hello\n body: Sent from the docs\n userId: 1\n responses:\n \"201\":\n description: Just a demo of the created post\n```\n\nEach part maps to something in the playground: `servers` sets the request target - and the only host the proxy will call - `tags` group endpoints in the sidebar, and `parameters` and `requestBody` become the inputs (adding a `securitySchemes` entry would produce authentication fields). Doccupine reads OpenAPI 3.0 and 3.1; see the [OpenAPI specification](https://spec.openapis.org) for the full format.\n\n## What gets generated\n\nEvery operation becomes its own page under `/api-reference/{tag}/{operation}`, showing:\n\n<Field value=\"Parameters\" type=\"path, query, header, cookie\">\nEach parameter is rendered with its name, type, and whether it is required, grouped into a collapsible section with an input to fill in.\n</Field>\n\n<Field value=\"Request body\" type=\"editable\">\nA JSON editor prefilled from the schema's example, ready to tweak and send.\n</Field>\n\n<Field value=\"Authentication\" type=\"from securitySchemes\">\nInputs for the endpoint's security schemes - API keys, bearer tokens, or basic auth - generated from the document.\n</Field>\n\n<Field value=\"Response\" type=\"live\">\nThe real status, timing, and body from your API, rendered to match its content type.\n</Field>\n\n## Embedding a single endpoint\n\nTo mix prose and a live endpoint on a hand-written page, reference an operation from the page's frontmatter with `openapi`. Use `METHOD /path` or an `operationId`:\n\n```mdx\n---\ntitle: \"Create a post\"\nopenapi: \"POST /posts\"\n---\n\nPosts are created for a user. The playground above is fully live - fill in the\nbody and send a real request.\n```\n\nDoccupine renders that endpoint's playground above your prose. If the reference does not match any operation in your document, the page still renders its prose and a warning is logged.\n\n## Running requests\n\nRequests run one of two ways, and readers can switch between them:\n\n<Callout type=\"note\">\n**Proxy (default).** The request is forwarded server-side, so it works even when the target API blocks cross-origin browser calls. **Direct.** The browser calls the API itself - useful when the API allows CORS and you want requests to never leave the reader's machine.\n</Callout>\n\nThe proxy is deliberately locked down. It only forwards to the servers declared in your OpenAPI document, refuses to reach private or internal network addresses, and never logs request URLs, headers, or bodies - so API keys a reader enters are not written anywhere.\n\n<Callout type=\"warning\">\nKeys and tokens a reader types are used only to make the request. Turn on \"Show secrets\" to reveal them in the generated code snippets; they are redacted by default.\n</Callout>\n\n## Responses and snippets\n\nResponses render to match their type: images and video play inline, everything else is shown as a formatted, syntax-highlighted body. Alongside the response, the playground generates ready-to-run **cURL**, **JavaScript**, and **Python** snippets for the exact request you built.\n\n## Documenting more than one API\n\nPass an array to document several APIs at once. Each spec becomes its own namespaced section:\n\n```json\n{\n \"openapi\": [\n { \"name\": \"public\", \"file\": \"specs/public.yaml\" },\n { \"name\": \"admin\", \"file\": \"specs/admin.yaml\" }\n ]\n}\n```\n";
1
+ export declare const apiPlaygroundMdxTemplate = "---\ntitle: \"API Playground\"\ndescription: \"Turn an OpenAPI document into an interactive API reference where readers send real requests and see live responses, right inside your docs.\"\ndate: \"2026-07-25\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 19\n---\n# API Playground\n\nPoint Doccupine at an OpenAPI document and it generates a complete, interactive API reference: one page per endpoint, grouped by tag in the sidebar, each with a \"Send request\" panel that makes real calls and shows the live response - plus copy-pasteable code snippets.\n\n<Callout type=\"note\">\nThe playground is driven entirely by your OpenAPI document. There is nothing to wire up by hand - add one line of config and every endpoint becomes a documented, runnable page.\n</Callout>\n\n## Try it\n\nPress **Try it** below to open the playground, tweak the request body, and send a real request to a live API - right from these docs.\n\n<ApiPlaygroundDemo />\n\n## Enabling the playground\n\n<Steps>\n <Step title=\"Add an openapi path to doccupine.json.\">\n Point at a local `.json`, `.yaml`, or `.yml` OpenAPI 3.0 or 3.1 document.\n\n```json\n{\n \"watchDir\": \"docs\",\n \"outputDir\": \"nextjs-app\",\n \"openapi\": \"openapi.yaml\"\n}\n```\n </Step>\n <Step title=\"Run Doccupine.\">\n On the next build (or live, while watching) Doccupine parses the document, resolves every `$ref`, and writes an endpoint page for each operation.\n </Step>\n <Step title=\"Open the API Reference section.\">\n Endpoints appear in the sidebar grouped by their OpenAPI tag. Editing the spec regenerates the pages automatically.\n </Step>\n</Steps>\n\n## Example spec\n\nDo not have a document yet? This `openapi.yaml` points at [JSONPlaceholder](https://jsonplaceholder.typicode.com), a free public test API, so it works end to end - save it, set `openapi` to it, and the generated pages can send real requests:\n\n```yaml\nopenapi: 3.1.0\ninfo:\n title: JSONPlaceholder\n version: 1.0.0\nservers:\n - url: https://jsonplaceholder.typicode.com\ntags:\n - name: Todos\n - name: Posts\npaths:\n /todos/{id}:\n get:\n summary: Get a to-do\n tags: [Todos]\n parameters:\n - name: id\n in: path\n required: true\n schema:\n type: integer\n responses:\n \"200\":\n description: Just a demo of a to-do item\n /posts:\n post:\n summary: Create a post\n tags: [Posts]\n requestBody:\n required: true\n content:\n application/json:\n example:\n title: Hello\n body: Sent from the docs\n userId: 1\n responses:\n \"201\":\n description: Just a demo of the created post\n```\n\nEach part maps to something in the playground: `servers` sets the request target - and the only host the proxy will call - `tags` group endpoints in the sidebar, and `parameters` and `requestBody` become the inputs (adding a `securitySchemes` entry would produce authentication fields). Doccupine reads OpenAPI 3.0 and 3.1; see the [OpenAPI specification](https://spec.openapis.org) for the full format.\n\n## What gets generated\n\nEvery operation becomes its own page under `/api-reference/{tag}/{operation}`, showing:\n\n<Field value=\"Parameters\" type=\"path, query, header, cookie\">\nEach parameter is rendered with its name, type, and whether it is required, grouped into a collapsible section with an input to fill in.\n</Field>\n\n<Field value=\"Request body\" type=\"editable\">\nA JSON editor prefilled from the schema's example, ready to tweak and send.\n</Field>\n\n<Field value=\"Authentication\" type=\"from securitySchemes\">\nInputs for the endpoint's security schemes - API keys, bearer tokens, or basic auth - generated from the document.\n</Field>\n\n<Field value=\"Response\" type=\"live\">\nThe real status, timing, and body from your API, rendered to match its content type.\n</Field>\n\n## Embedding a single endpoint\n\nTo mix prose and a live endpoint on a hand-written page, reference an operation from the page's frontmatter with `openapi`. Use `METHOD /path` or an `operationId`:\n\n```mdx\n---\ntitle: \"Create a post\"\nopenapi: \"POST /posts\"\n---\n\nPosts are created for a user. The playground above is fully live - fill in the\nbody and send a real request.\n```\n\nDoccupine renders that endpoint's playground above your prose. If the reference does not match any operation in your document, the page still renders its prose and a warning is logged.\n\n## Running requests\n\nRequests run one of two ways, and readers can switch between them:\n\n<Callout type=\"note\">\n**Proxy (default).** The request is forwarded server-side, so it works even when the target API blocks cross-origin browser calls. **Direct.** The browser calls the API itself - useful when the API allows CORS and you want requests to never leave the reader's machine.\n</Callout>\n\nThe proxy is deliberately locked down. It only forwards to the servers declared in your OpenAPI document, refuses to reach private or internal network addresses, and never logs request URLs, headers, or bodies - so API keys a reader enters are not written anywhere.\n\n<Callout type=\"warning\">\nKeys and tokens a reader types are used only to make the request. Turn on \"Show secrets\" to reveal them in the generated code snippets; they are redacted by default.\n</Callout>\n\n## Responses and snippets\n\nResponses render to match their type: images and video play inline, everything else is shown as a formatted, syntax-highlighted body. Alongside the response, the playground generates ready-to-run **cURL**, **JavaScript**, and **Python** snippets for the exact request you built.\n\n## Documenting more than one API\n\nPass an array to document several APIs at once. Each spec becomes its own namespaced section:\n\n```json\n{\n \"openapi\": [\n { \"name\": \"public\", \"file\": \"specs/public.yaml\" },\n { \"name\": \"admin\", \"file\": \"specs/admin.yaml\" }\n ]\n}\n```\n";
@@ -4,7 +4,7 @@ description: "Turn an OpenAPI document into an interactive API reference where r
4
4
  date: "2026-07-25"
5
5
  category: "Components"
6
6
  categoryOrder: 1
7
- order: 15
7
+ order: 19
8
8
  ---
9
9
  # API Playground
10
10