ardo 2.7.2 → 2.8.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.
@@ -333,8 +333,8 @@ declare function ThemeToggle(): react_jsx_runtime.JSX.Element;
333
333
  declare function Search(): react_jsx_runtime.JSX.Element;
334
334
 
335
335
  interface CodeBlockProps {
336
- /** The code to display */
337
- code: string;
336
+ /** The code to display (as prop or as children string) */
337
+ code?: string;
338
338
  /** Programming language for syntax highlighting */
339
339
  language?: string;
340
340
  /** Optional title shown above the code */
@@ -343,13 +343,24 @@ interface CodeBlockProps {
343
343
  lineNumbers?: boolean;
344
344
  /** Line numbers to highlight */
345
345
  highlightLines?: number[];
346
- /** Optional custom content to render instead of the code */
346
+ /** Code as children supports template literals with auto-outdent */
347
347
  children?: React.ReactNode;
348
+ /** Pre-rendered Shiki HTML (injected by ardo:codeblock-highlight plugin) */
349
+ __html?: string;
348
350
  }
349
351
  /**
350
352
  * Syntax-highlighted code block with copy button.
353
+ *
354
+ * Code can be provided via the `code` prop or as children:
355
+ * ```tsx
356
+ * <CodeBlock language="typescript">{`
357
+ * const x = 42
358
+ * `}</CodeBlock>
359
+ * ```
360
+ * When children is a string, leading/trailing blank lines and common
361
+ * indentation are stripped automatically.
351
362
  */
352
- declare function CodeBlock({ code, language, title, lineNumbers, highlightLines, children, }: CodeBlockProps): react_jsx_runtime.JSX.Element;
363
+ declare function CodeBlock({ code: codeProp, language, title, lineNumbers, highlightLines, children, __html, }: CodeBlockProps): react_jsx_runtime.JSX.Element;
353
364
  interface CodeGroupProps {
354
365
  /** CodeBlock components to display as tabs */
355
366
  children: React.ReactNode;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Content
3
- } from "./chunk-6MXVILOZ.js";
3
+ } from "./chunk-TUXQC2BT.js";
4
4
  import {
5
5
  ChevronDownIcon,
6
6
  GithubIcon,
@@ -841,4 +841,4 @@ export {
841
841
  Steps,
842
842
  FileTree
843
843
  };
844
- //# sourceMappingURL=chunk-2JWOR7PG.js.map
844
+ //# sourceMappingURL=chunk-D3I3T743.js.map
@@ -16,14 +16,29 @@ import {
16
16
  useThemeConfig
17
17
  } from "./chunk-QELSOHIY.js";
18
18
 
19
+ // src/ui/BareContent.tsx
20
+ import { createContext, useContext } from "react";
21
+ import { jsx } from "react/jsx-runtime";
22
+ var BareContentContext = createContext(false);
23
+ function BareContent({ children }) {
24
+ return /* @__PURE__ */ jsx(BareContentContext, { value: true, children });
25
+ }
26
+ function useBareContent() {
27
+ return useContext(BareContentContext);
28
+ }
29
+
19
30
  // src/ui/Content.tsx
20
31
  import { Link, useLocation } from "react-router";
21
- import { jsx, jsxs } from "react/jsx-runtime";
32
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
22
33
  function Content({ children }) {
34
+ const isBare = useBareContent();
23
35
  const pageData = usePageData();
24
36
  const themeConfig = useThemeConfig();
25
37
  const sidebar = useSidebar();
26
38
  const location = useLocation();
39
+ if (isBare) {
40
+ return /* @__PURE__ */ jsx2("div", { className: "ardo-content-body ardo-content", children });
41
+ }
27
42
  const { prev, next } = getPrevNextLinks(sidebar, location.pathname);
28
43
  const showEditLink = pageData?.frontmatter.editLink !== false && themeConfig.editLink?.pattern;
29
44
  const showLastUpdated = pageData?.frontmatter.lastUpdated !== false && themeConfig.lastUpdated?.enabled && pageData?.lastUpdated;
@@ -38,13 +53,13 @@ function Content({ children }) {
38
53
  ) : null;
39
54
  return /* @__PURE__ */ jsxs("article", { className: "ardo-content-container", children: [
40
55
  pageData?.frontmatter.title && /* @__PURE__ */ jsxs("header", { className: "ardo-content-header", children: [
41
- /* @__PURE__ */ jsx("h1", { className: "ardo-content-title", children: pageData.frontmatter.title }),
42
- pageData.frontmatter.description && /* @__PURE__ */ jsx("p", { className: "ardo-content-description", children: pageData.frontmatter.description })
56
+ /* @__PURE__ */ jsx2("h1", { className: "ardo-content-title", children: pageData.frontmatter.title }),
57
+ pageData.frontmatter.description && /* @__PURE__ */ jsx2("p", { className: "ardo-content-description", children: pageData.frontmatter.description })
43
58
  ] }),
44
- /* @__PURE__ */ jsx("div", { className: "ardo-content-body ardo-content", children }),
59
+ /* @__PURE__ */ jsx2("div", { className: "ardo-content-body ardo-content", children }),
45
60
  /* @__PURE__ */ jsxs("footer", { className: "ardo-content-footer", children: [
46
61
  (showEditLink || showLastUpdated) && /* @__PURE__ */ jsxs("div", { className: "ardo-content-meta", children: [
47
- showEditLink && /* @__PURE__ */ jsx(
62
+ showEditLink && /* @__PURE__ */ jsx2(
48
63
  "a",
49
64
  {
50
65
  href: editLink,
@@ -62,20 +77,20 @@ function Content({ children }) {
62
77
  ] }),
63
78
  (prev || next) && /* @__PURE__ */ jsxs("nav", { className: "ardo-prev-next", "aria-label": "Page navigation", children: [
64
79
  prev ? /* @__PURE__ */ jsxs(Link, { to: prev.link, className: "ardo-prev-link", children: [
65
- /* @__PURE__ */ jsx("span", { className: "ardo-prev-next-label", children: "Previous" }),
66
- /* @__PURE__ */ jsx("span", { className: "ardo-prev-next-title", children: prev.text })
67
- ] }) : /* @__PURE__ */ jsx("div", {}),
80
+ /* @__PURE__ */ jsx2("span", { className: "ardo-prev-next-label", children: "Previous" }),
81
+ /* @__PURE__ */ jsx2("span", { className: "ardo-prev-next-title", children: prev.text })
82
+ ] }) : /* @__PURE__ */ jsx2("div", {}),
68
83
  next ? /* @__PURE__ */ jsxs(Link, { to: next.link, className: "ardo-next-link", children: [
69
- /* @__PURE__ */ jsx("span", { className: "ardo-prev-next-label", children: "Next" }),
70
- /* @__PURE__ */ jsx("span", { className: "ardo-prev-next-title", children: next.text })
71
- ] }) : /* @__PURE__ */ jsx("div", {})
84
+ /* @__PURE__ */ jsx2("span", { className: "ardo-prev-next-label", children: "Next" }),
85
+ /* @__PURE__ */ jsx2("span", { className: "ardo-prev-next-title", children: next.text })
86
+ ] }) : /* @__PURE__ */ jsx2("div", {})
72
87
  ] })
73
88
  ] })
74
89
  ] });
75
90
  }
76
91
 
77
92
  // src/ui/components/Icon.tsx
78
- import { jsx as jsx2 } from "react/jsx-runtime";
93
+ import { jsx as jsx3 } from "react/jsx-runtime";
79
94
  var iconRegistry = /* @__PURE__ */ new Map();
80
95
  function registerIcons(icons2) {
81
96
  for (const [name, icon] of Object.entries(icons2)) {
@@ -91,12 +106,12 @@ function Icon({ name, ...props }) {
91
106
  console.warn(`[Ardo] Icon "${name}" not found. Did you register it with registerIcons()?`);
92
107
  return null;
93
108
  }
94
- return /* @__PURE__ */ jsx2(IconComp, { ...props });
109
+ return /* @__PURE__ */ jsx3(IconComp, { ...props });
95
110
  }
96
111
 
97
112
  // src/ui/components/CopyButton.tsx
98
113
  import { useState } from "react";
99
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
114
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
100
115
  function CopyButton({ code }) {
101
116
  const [copied, setCopied] = useState(false);
102
117
  const handleCopy = async () => {
@@ -115,8 +130,8 @@ function CopyButton({ code }) {
115
130
  onClick: handleCopy,
116
131
  "aria-label": copied ? "Copied!" : "Copy code",
117
132
  children: [
118
- copied ? /* @__PURE__ */ jsx3(CheckIcon, { size: 16 }) : /* @__PURE__ */ jsx3(CopyIcon, { size: 16 }),
119
- /* @__PURE__ */ jsx3("span", { className: "ardo-copy-text", children: copied ? "Copied!" : "Copy" })
133
+ copied ? /* @__PURE__ */ jsx4(CheckIcon, { size: 16 }) : /* @__PURE__ */ jsx4(CopyIcon, { size: 16 }),
134
+ /* @__PURE__ */ jsx4("span", { className: "ardo-copy-text", children: copied ? "Copied!" : "Copy" })
120
135
  ]
121
136
  }
122
137
  );
@@ -124,31 +139,53 @@ function CopyButton({ code }) {
124
139
 
125
140
  // src/ui/components/CodeBlock.tsx
126
141
  import { useState as useState2, Children, isValidElement } from "react";
127
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
142
+ import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
143
+ function outdent(text) {
144
+ const trimmed = text.replace(/^\n+/, "").replace(/\n\s*$/, "");
145
+ const lines = trimmed.split("\n");
146
+ const indent = lines.reduce((min, line) => {
147
+ if (line.trim().length === 0) return min;
148
+ const match = line.match(/^(\s*)/);
149
+ return match ? Math.min(min, match[1].length) : min;
150
+ }, Infinity);
151
+ if (indent === 0 || indent === Infinity) return trimmed;
152
+ return lines.map((line) => line.slice(indent)).join("\n");
153
+ }
128
154
  function CodeBlock({
129
- code,
155
+ code: codeProp,
130
156
  language = "text",
131
157
  title,
132
158
  lineNumbers = false,
133
159
  highlightLines = [],
134
- children
160
+ children,
161
+ __html
135
162
  }) {
163
+ const code = codeProp ?? (typeof children === "string" ? outdent(children) : "");
164
+ const hasCustomChildren = children != null && typeof children !== "string";
136
165
  const lines = code.split("\n");
166
+ let content;
167
+ if (__html) {
168
+ content = /* @__PURE__ */ jsx5("div", { dangerouslySetInnerHTML: { __html } });
169
+ } else if (hasCustomChildren) {
170
+ content = /* @__PURE__ */ jsx5(Fragment, { children });
171
+ } else {
172
+ content = /* @__PURE__ */ jsx5("pre", { className: `language-${language}`, children: /* @__PURE__ */ jsx5("code", { children: lines.map((line, index) => {
173
+ const lineNum = index + 1;
174
+ const isHighlighted = highlightLines.includes(lineNum);
175
+ const classes = ["ardo-code-line"];
176
+ if (isHighlighted) classes.push("highlighted");
177
+ return /* @__PURE__ */ jsxs3("span", { className: classes.join(" "), children: [
178
+ lineNumbers && /* @__PURE__ */ jsx5("span", { className: "ardo-line-number", children: lineNum }),
179
+ /* @__PURE__ */ jsx5("span", { className: "ardo-line-content", children: line }),
180
+ index < lines.length - 1 && "\n"
181
+ ] }, index);
182
+ }) }) });
183
+ }
137
184
  return /* @__PURE__ */ jsxs3("div", { className: "ardo-code-block", "data-lang": language, children: [
138
- title && /* @__PURE__ */ jsx4("div", { className: "ardo-code-title", children: title }),
185
+ title && /* @__PURE__ */ jsx5("div", { className: "ardo-code-title", children: title }),
139
186
  /* @__PURE__ */ jsxs3("div", { className: "ardo-code-wrapper", children: [
140
- children || /* @__PURE__ */ jsx4("pre", { className: `language-${language}`, children: /* @__PURE__ */ jsx4("code", { children: lines.map((line, index) => {
141
- const lineNum = index + 1;
142
- const isHighlighted = highlightLines.includes(lineNum);
143
- const classes = ["ardo-code-line"];
144
- if (isHighlighted) classes.push("highlighted");
145
- return /* @__PURE__ */ jsxs3("span", { className: classes.join(" "), children: [
146
- lineNumbers && /* @__PURE__ */ jsx4("span", { className: "ardo-line-number", children: lineNum }),
147
- /* @__PURE__ */ jsx4("span", { className: "ardo-line-content", children: line }),
148
- index < lines.length - 1 && "\n"
149
- ] }, index);
150
- }) }) }),
151
- /* @__PURE__ */ jsx4(CopyButton, { code })
187
+ content,
188
+ /* @__PURE__ */ jsx5(CopyButton, { code })
152
189
  ] })
153
190
  ] });
154
191
  }
@@ -162,7 +199,7 @@ function CodeGroup({ children, labels: labelsStr }) {
162
199
  return props["data-label"] || props.title || props.language || `Tab ${index + 1}`;
163
200
  });
164
201
  return /* @__PURE__ */ jsxs3("div", { className: "ardo-code-group", children: [
165
- /* @__PURE__ */ jsx4("div", { className: "ardo-code-group-tabs", children: tabs.map((tab, index) => /* @__PURE__ */ jsx4(
202
+ /* @__PURE__ */ jsx5("div", { className: "ardo-code-group-tabs", children: tabs.map((tab, index) => /* @__PURE__ */ jsx5(
166
203
  "button",
167
204
  {
168
205
  className: ["ardo-code-group-tab", index === activeTab && "active"].filter(Boolean).join(" "),
@@ -171,7 +208,7 @@ function CodeGroup({ children, labels: labelsStr }) {
171
208
  },
172
209
  index
173
210
  )) }),
174
- /* @__PURE__ */ jsx4("div", { className: "ardo-code-group-panels", children: childArray.map((child, index) => /* @__PURE__ */ jsx4(
211
+ /* @__PURE__ */ jsx5("div", { className: "ardo-code-group-panels", children: childArray.map((child, index) => /* @__PURE__ */ jsx5(
175
212
  "div",
176
213
  {
177
214
  className: ["ardo-code-group-panel", index === activeTab && "active"].filter(Boolean).join(" "),
@@ -184,7 +221,7 @@ function CodeGroup({ children, labels: labelsStr }) {
184
221
  }
185
222
 
186
223
  // src/ui/components/Container.tsx
187
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
224
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
188
225
  var defaultTitles = {
189
226
  tip: "TIP",
190
227
  warning: "WARNING",
@@ -193,44 +230,44 @@ var defaultTitles = {
193
230
  note: "NOTE"
194
231
  };
195
232
  var icons = {
196
- tip: /* @__PURE__ */ jsx5(LightbulbIcon, { size: 18 }),
197
- warning: /* @__PURE__ */ jsx5(AlertTriangleIcon, { size: 18 }),
198
- danger: /* @__PURE__ */ jsx5(XCircleIcon, { size: 18 }),
199
- info: /* @__PURE__ */ jsx5(InfoIcon, { size: 18 }),
200
- note: /* @__PURE__ */ jsx5(FileTextIcon, { size: 18 })
233
+ tip: /* @__PURE__ */ jsx6(LightbulbIcon, { size: 18 }),
234
+ warning: /* @__PURE__ */ jsx6(AlertTriangleIcon, { size: 18 }),
235
+ danger: /* @__PURE__ */ jsx6(XCircleIcon, { size: 18 }),
236
+ info: /* @__PURE__ */ jsx6(InfoIcon, { size: 18 }),
237
+ note: /* @__PURE__ */ jsx6(FileTextIcon, { size: 18 })
201
238
  };
202
239
  function Container({ type, title, children }) {
203
240
  const displayTitle = title || defaultTitles[type];
204
241
  return /* @__PURE__ */ jsxs4("div", { className: `ardo-container ardo-container-${type}`, children: [
205
242
  /* @__PURE__ */ jsxs4("p", { className: "ardo-container-title", children: [
206
- /* @__PURE__ */ jsx5("span", { className: "ardo-container-icon", children: icons[type] }),
243
+ /* @__PURE__ */ jsx6("span", { className: "ardo-container-icon", children: icons[type] }),
207
244
  displayTitle
208
245
  ] }),
209
- /* @__PURE__ */ jsx5("div", { className: "ardo-container-content", children })
246
+ /* @__PURE__ */ jsx6("div", { className: "ardo-container-content", children })
210
247
  ] });
211
248
  }
212
249
  function Tip({ title, children }) {
213
- return /* @__PURE__ */ jsx5(Container, { type: "tip", title, children });
250
+ return /* @__PURE__ */ jsx6(Container, { type: "tip", title, children });
214
251
  }
215
252
  function Warning({ title, children }) {
216
- return /* @__PURE__ */ jsx5(Container, { type: "warning", title, children });
253
+ return /* @__PURE__ */ jsx6(Container, { type: "warning", title, children });
217
254
  }
218
255
  function Danger({ title, children }) {
219
- return /* @__PURE__ */ jsx5(Container, { type: "danger", title, children });
256
+ return /* @__PURE__ */ jsx6(Container, { type: "danger", title, children });
220
257
  }
221
258
  function Info({ title, children }) {
222
- return /* @__PURE__ */ jsx5(Container, { type: "info", title, children });
259
+ return /* @__PURE__ */ jsx6(Container, { type: "info", title, children });
223
260
  }
224
261
  function Note({ title, children }) {
225
- return /* @__PURE__ */ jsx5(Container, { type: "note", title, children });
262
+ return /* @__PURE__ */ jsx6(Container, { type: "note", title, children });
226
263
  }
227
264
 
228
265
  // src/ui/components/Tabs.tsx
229
- import { useState as useState3, createContext, useContext } from "react";
230
- import { jsx as jsx6 } from "react/jsx-runtime";
231
- var TabsContext = createContext(null);
266
+ import { useState as useState3, createContext as createContext2, useContext as useContext2 } from "react";
267
+ import { jsx as jsx7 } from "react/jsx-runtime";
268
+ var TabsContext = createContext2(null);
232
269
  function useTabsContext() {
233
- const context = useContext(TabsContext);
270
+ const context = useContext2(TabsContext);
234
271
  if (!context) {
235
272
  throw new Error("Tab components must be used within a Tabs component");
236
273
  }
@@ -238,15 +275,15 @@ function useTabsContext() {
238
275
  }
239
276
  function Tabs({ defaultValue, children }) {
240
277
  const [activeTab, setActiveTab] = useState3(defaultValue || "");
241
- return /* @__PURE__ */ jsx6(TabsContext.Provider, { value: { activeTab, setActiveTab }, children: /* @__PURE__ */ jsx6("div", { className: "ardo-tabs", children }) });
278
+ return /* @__PURE__ */ jsx7(TabsContext.Provider, { value: { activeTab, setActiveTab }, children: /* @__PURE__ */ jsx7("div", { className: "ardo-tabs", children }) });
242
279
  }
243
280
  function TabList({ children }) {
244
- return /* @__PURE__ */ jsx6("div", { className: "ardo-tab-list", role: "tablist", children });
281
+ return /* @__PURE__ */ jsx7("div", { className: "ardo-tab-list", role: "tablist", children });
245
282
  }
246
283
  function Tab({ value, children }) {
247
284
  const { activeTab, setActiveTab } = useTabsContext();
248
285
  const isActive = activeTab === value;
249
- return /* @__PURE__ */ jsx6(
286
+ return /* @__PURE__ */ jsx7(
250
287
  "button",
251
288
  {
252
289
  role: "tab",
@@ -263,13 +300,14 @@ function TabPanel({ value, children }) {
263
300
  if (!isActive) {
264
301
  return null;
265
302
  }
266
- return /* @__PURE__ */ jsx6("div", { role: "tabpanel", className: "ardo-tab-panel", children });
303
+ return /* @__PURE__ */ jsx7("div", { role: "tabpanel", className: "ardo-tab-panel", children });
267
304
  }
268
305
  function TabPanels({ children }) {
269
- return /* @__PURE__ */ jsx6("div", { className: "ardo-tab-panels", children });
306
+ return /* @__PURE__ */ jsx7("div", { className: "ardo-tab-panels", children });
270
307
  }
271
308
 
272
309
  export {
310
+ BareContent,
273
311
  Content,
274
312
  registerIcons,
275
313
  getRegisteredIconNames,
@@ -289,4 +327,4 @@ export {
289
327
  TabPanel,
290
328
  TabPanels
291
329
  };
292
- //# sourceMappingURL=chunk-6MXVILOZ.js.map
330
+ //# sourceMappingURL=chunk-TUXQC2BT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/BareContent.tsx","../src/ui/Content.tsx","../src/ui/components/Icon.tsx","../src/ui/components/CopyButton.tsx","../src/ui/components/CodeBlock.tsx","../src/ui/components/Container.tsx","../src/ui/components/Tabs.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\"\n\nconst BareContentContext = createContext(false)\n\n/**\n * Wraps imported MDX content to render without the full Content wrapper\n * (article, header, footer, navigation). Only the content body is rendered.\n *\n * ```tsx\n * import MySnippet from \"./snippet.mdx\"\n *\n * <BareContent>\n * <MySnippet />\n * </BareContent>\n * ```\n */\nexport function BareContent({ children }: { children: ReactNode }) {\n return <BareContentContext value={true}>{children}</BareContentContext>\n}\n\nexport function useBareContent(): boolean {\n return useContext(BareContentContext)\n}\n","import { type ReactNode } from \"react\"\nimport { usePageData, useThemeConfig, useSidebar } from \"../runtime/hooks\"\nimport { getPrevNextLinks } from \"../runtime/sidebar-utils\"\nimport { Link, useLocation } from \"react-router\"\nimport { useBareContent } from \"./BareContent\"\n\ninterface ContentProps {\n children: ReactNode\n}\n\nexport function Content({ children }: ContentProps) {\n const isBare = useBareContent()\n const pageData = usePageData()\n const themeConfig = useThemeConfig()\n const sidebar = useSidebar()\n const location = useLocation()\n\n if (isBare) {\n return <div className=\"ardo-content-body ardo-content\">{children}</div>\n }\n\n const { prev, next } = getPrevNextLinks(sidebar, location.pathname)\n\n const showEditLink = pageData?.frontmatter.editLink !== false && themeConfig.editLink?.pattern\n\n const showLastUpdated =\n pageData?.frontmatter.lastUpdated !== false &&\n themeConfig.lastUpdated?.enabled &&\n pageData?.lastUpdated\n\n const editLink = showEditLink\n ? themeConfig.editLink!.pattern.replace(\":path\", pageData?.relativePath || \"\")\n : null\n\n const lastUpdatedText = showLastUpdated\n ? new Date(pageData!.lastUpdated!).toLocaleDateString(\n undefined,\n themeConfig.lastUpdated?.formatOptions ?? {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n }\n )\n : null\n\n return (\n <article className=\"ardo-content-container\">\n {pageData?.frontmatter.title && (\n <header className=\"ardo-content-header\">\n <h1 className=\"ardo-content-title\">{pageData.frontmatter.title}</h1>\n {pageData.frontmatter.description && (\n <p className=\"ardo-content-description\">{pageData.frontmatter.description}</p>\n )}\n </header>\n )}\n\n <div className=\"ardo-content-body ardo-content\">{children}</div>\n\n <footer className=\"ardo-content-footer\">\n {(showEditLink || showLastUpdated) && (\n <div className=\"ardo-content-meta\">\n {showEditLink && (\n <a\n href={editLink!}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"ardo-edit-link\"\n >\n {themeConfig.editLink?.text ?? \"Edit this page\"}\n </a>\n )}\n {showLastUpdated && (\n <span className=\"ardo-last-updated\">\n {themeConfig.lastUpdated?.text ?? \"Last updated\"}: {lastUpdatedText}\n </span>\n )}\n </div>\n )}\n\n {(prev || next) && (\n <nav className=\"ardo-prev-next\" aria-label=\"Page navigation\">\n {prev ? (\n <Link to={prev.link!} className=\"ardo-prev-link\">\n <span className=\"ardo-prev-next-label\">Previous</span>\n <span className=\"ardo-prev-next-title\">{prev.text}</span>\n </Link>\n ) : (\n <div />\n )}\n {next ? (\n <Link to={next.link!} className=\"ardo-next-link\">\n <span className=\"ardo-prev-next-label\">Next</span>\n <span className=\"ardo-prev-next-title\">{next.text}</span>\n </Link>\n ) : (\n <div />\n )}\n </nav>\n )}\n </footer>\n </article>\n )\n}\n","import type { ComponentType, SVGAttributes, ReactNode } from \"react\"\n\ntype IconComponent = ComponentType<SVGAttributes<SVGSVGElement> & { size?: number }>\n\nexport interface IconProps extends SVGAttributes<SVGSVGElement> {\n /** Name of the registered icon */\n name: string\n /** Icon size */\n size?: number\n}\n\n// Icon registry - users register only the icons they need\nconst iconRegistry = new Map<string, IconComponent>()\n\n/**\n * Register icons for use with the Icon component.\n * Only registered icons are included in your bundle.\n *\n * @example\n * ```tsx\n * // In your app's entry point or layout:\n * import { registerIcons } from \"ardo/ui\"\n * import { Zap, Rocket, Code } from \"lucide-react\"\n *\n * registerIcons({ Zap, Rocket, Code })\n * ```\n */\nexport function registerIcons(icons: Record<string, IconComponent>): void {\n for (const [name, icon] of Object.entries(icons)) {\n iconRegistry.set(name, icon)\n }\n}\n\n/**\n * Get all registered icon names (useful for documentation).\n */\nexport function getRegisteredIconNames(): string[] {\n return Array.from(iconRegistry.keys())\n}\n\n/**\n * Renders a registered icon by name.\n * Icons must be registered first using `registerIcons()`.\n *\n * @example\n * ```tsx\n * // First register icons in your app:\n * import { registerIcons } from \"ardo/ui\"\n * import { Zap, Rocket } from \"lucide-react\"\n * registerIcons({ Zap, Rocket })\n *\n * // Then use in MDX:\n * <Icon name=\"Zap\" size={24} />\n * <Icon name=\"Rocket\" className=\"text-brand\" />\n * ```\n *\n * @see https://lucide.dev/icons for available icon names\n */\nexport function Icon({ name, ...props }: IconProps): ReactNode {\n const IconComp = iconRegistry.get(name)\n\n if (!IconComp) {\n console.warn(`[Ardo] Icon \"${name}\" not found. Did you register it with registerIcons()?`)\n return null\n }\n\n return <IconComp {...props} />\n}\n","import { useState } from \"react\"\nimport { CopyIcon, CheckIcon } from \"../icons\"\n\ninterface CopyButtonProps {\n code: string\n}\n\nexport function CopyButton({ code }: CopyButtonProps) {\n const [copied, setCopied] = useState(false)\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code)\n setCopied(true)\n setTimeout(() => setCopied(false), 2000)\n } catch (err) {\n console.error(\"Failed to copy:\", err)\n }\n }\n\n return (\n <button\n className=\"ardo-copy-button\"\n onClick={handleCopy}\n aria-label={copied ? \"Copied!\" : \"Copy code\"}\n >\n {copied ? <CheckIcon size={16} /> : <CopyIcon size={16} />}\n <span className=\"ardo-copy-text\">{copied ? \"Copied!\" : \"Copy\"}</span>\n </button>\n )\n}\n","import { useState, Children, isValidElement } from \"react\"\nimport { CopyButton } from \"./CopyButton\"\n\n/**\n * Strips leading/trailing blank lines and removes common leading whitespace\n * so that template literals in indented JSX render cleanly.\n */\nfunction outdent(text: string): string {\n // Remove leading/trailing blank lines\n const trimmed = text.replace(/^\\n+/, \"\").replace(/\\n\\s*$/, \"\")\n const lines = trimmed.split(\"\\n\")\n\n // Find minimum indentation (ignoring empty lines)\n const indent = lines.reduce((min, line) => {\n if (line.trim().length === 0) return min\n const match = line.match(/^(\\s*)/)\n return match ? Math.min(min, match[1].length) : min\n }, Infinity)\n\n if (indent === 0 || indent === Infinity) return trimmed\n return lines.map((line) => line.slice(indent)).join(\"\\n\")\n}\n\nexport interface CodeBlockProps {\n /** The code to display (as prop or as children string) */\n code?: string\n /** Programming language for syntax highlighting */\n language?: string\n /** Optional title shown above the code */\n title?: string\n /** Show line numbers */\n lineNumbers?: boolean\n /** Line numbers to highlight */\n highlightLines?: number[]\n /** Code as children — supports template literals with auto-outdent */\n children?: React.ReactNode\n /** Pre-rendered Shiki HTML (injected by ardo:codeblock-highlight plugin) */\n __html?: string\n}\n\n/**\n * Syntax-highlighted code block with copy button.\n *\n * Code can be provided via the `code` prop or as children:\n * ```tsx\n * <CodeBlock language=\"typescript\">{`\n * const x = 42\n * `}</CodeBlock>\n * ```\n * When children is a string, leading/trailing blank lines and common\n * indentation are stripped automatically.\n */\nexport function CodeBlock({\n code: codeProp,\n language = \"text\",\n title,\n lineNumbers = false,\n highlightLines = [],\n children,\n __html,\n}: CodeBlockProps) {\n const code = codeProp ?? (typeof children === \"string\" ? outdent(children) : \"\")\n const hasCustomChildren = children != null && typeof children !== \"string\"\n const lines = code.split(\"\\n\")\n\n let content: React.ReactNode\n if (__html) {\n content = <div dangerouslySetInnerHTML={{ __html }} />\n } else if (hasCustomChildren) {\n content = <>{children}</>\n } else {\n content = (\n <pre className={`language-${language}`}>\n <code>\n {lines.map((line, index) => {\n const lineNum = index + 1\n const isHighlighted = highlightLines.includes(lineNum)\n const classes = [\"ardo-code-line\"]\n if (isHighlighted) classes.push(\"highlighted\")\n\n return (\n <span key={index} className={classes.join(\" \")}>\n {lineNumbers && <span className=\"ardo-line-number\">{lineNum}</span>}\n <span className=\"ardo-line-content\">{line}</span>\n {index < lines.length - 1 && \"\\n\"}\n </span>\n )\n })}\n </code>\n </pre>\n )\n }\n\n return (\n <div className=\"ardo-code-block\" data-lang={language}>\n {title && <div className=\"ardo-code-title\">{title}</div>}\n <div className=\"ardo-code-wrapper\">\n {content}\n <CopyButton code={code} />\n </div>\n </div>\n )\n}\n\nexport interface CodeGroupProps {\n /** CodeBlock components to display as tabs */\n children: React.ReactNode\n /** Comma-separated tab labels (set by remarkContainersMdx from code block meta) */\n labels?: string\n}\n\n/**\n * Tabbed group of code blocks.\n * Labels come from the `labels` prop (set at remark level) or fall back to\n * data-label / title / language props on children.\n */\nexport function CodeGroup({ children, labels: labelsStr }: CodeGroupProps) {\n const [activeTab, setActiveTab] = useState(0)\n\n // Filter to only valid React elements (skip whitespace text nodes)\n const childArray = Children.toArray(children).filter(isValidElement)\n const labelArray = labelsStr ? labelsStr.split(\",\") : []\n const tabs = childArray.map((child, index) => {\n if (labelArray[index]) return labelArray[index]\n const props = child.props as Record<string, unknown>\n return (\n (props[\"data-label\"] as string) ||\n (props.title as string) ||\n (props.language as string) ||\n `Tab ${index + 1}`\n )\n })\n\n return (\n <div className=\"ardo-code-group\">\n <div className=\"ardo-code-group-tabs\">\n {tabs.map((tab, index) => (\n <button\n key={index}\n className={[\"ardo-code-group-tab\", index === activeTab && \"active\"]\n .filter(Boolean)\n .join(\" \")}\n onClick={() => setActiveTab(index)}\n >\n {tab}\n </button>\n ))}\n </div>\n <div className=\"ardo-code-group-panels\">\n {childArray.map((child, index) => (\n <div\n key={index}\n className={[\"ardo-code-group-panel\", index === activeTab && \"active\"]\n .filter(Boolean)\n .join(\" \")}\n style={{ display: index === activeTab ? \"block\" : \"none\" }}\n >\n {child}\n </div>\n ))}\n </div>\n </div>\n )\n}\n","import { type ReactNode } from \"react\"\nimport { LightbulbIcon, AlertTriangleIcon, XCircleIcon, InfoIcon, FileTextIcon } from \"../icons\"\n\nexport type ContainerType = \"tip\" | \"warning\" | \"danger\" | \"info\" | \"note\"\n\nexport interface ContainerProps {\n /** Container type determining the style */\n type: ContainerType\n /** Optional custom title */\n title?: string\n /** Content to display inside the container */\n children: ReactNode\n}\n\nconst defaultTitles: Record<ContainerType, string> = {\n tip: \"TIP\",\n warning: \"WARNING\",\n danger: \"DANGER\",\n info: \"INFO\",\n note: \"NOTE\",\n}\n\nconst icons: Record<ContainerType, ReactNode> = {\n tip: <LightbulbIcon size={18} />,\n warning: <AlertTriangleIcon size={18} />,\n danger: <XCircleIcon size={18} />,\n info: <InfoIcon size={18} />,\n note: <FileTextIcon size={18} />,\n}\n\n/**\n * A styled container for callouts, tips, warnings, etc.\n */\nexport function Container({ type, title, children }: ContainerProps) {\n const displayTitle = title || defaultTitles[type]\n\n return (\n <div className={`ardo-container ardo-container-${type}`}>\n <p className=\"ardo-container-title\">\n <span className=\"ardo-container-icon\">{icons[type]}</span>\n {displayTitle}\n </p>\n <div className=\"ardo-container-content\">{children}</div>\n </div>\n )\n}\n\nexport interface TipProps {\n /** Optional custom title */\n title?: string\n /** Content to display */\n children: ReactNode\n}\n\n/**\n * A tip container for helpful information.\n */\nexport function Tip({ title, children }: TipProps) {\n return (\n <Container type=\"tip\" title={title}>\n {children}\n </Container>\n )\n}\n\nexport interface WarningProps {\n /** Optional custom title */\n title?: string\n /** Content to display */\n children: ReactNode\n}\n\n/**\n * A warning container for cautionary information.\n */\nexport function Warning({ title, children }: WarningProps) {\n return (\n <Container type=\"warning\" title={title}>\n {children}\n </Container>\n )\n}\n\nexport interface DangerProps {\n /** Optional custom title */\n title?: string\n /** Content to display */\n children: ReactNode\n}\n\n/**\n * A danger container for critical warnings.\n */\nexport function Danger({ title, children }: DangerProps) {\n return (\n <Container type=\"danger\" title={title}>\n {children}\n </Container>\n )\n}\n\nexport interface InfoProps {\n /** Optional custom title */\n title?: string\n /** Content to display */\n children: ReactNode\n}\n\n/**\n * An info container for informational content.\n */\nexport function Info({ title, children }: InfoProps) {\n return (\n <Container type=\"info\" title={title}>\n {children}\n </Container>\n )\n}\n\nexport interface NoteProps {\n /** Optional custom title */\n title?: string\n /** Content to display */\n children: ReactNode\n}\n\n/**\n * A note container for additional information.\n */\nexport function Note({ title, children }: NoteProps) {\n return (\n <Container type=\"note\" title={title}>\n {children}\n </Container>\n )\n}\n","import { useState, createContext, useContext, type ReactNode } from \"react\"\n\ninterface TabsContextValue {\n activeTab: string\n setActiveTab: (tab: string) => void\n}\n\nconst TabsContext = createContext<TabsContextValue | null>(null)\n\nfunction useTabsContext() {\n const context = useContext(TabsContext)\n if (!context) {\n throw new Error(\"Tab components must be used within a Tabs component\")\n }\n return context\n}\n\nexport interface TabsProps {\n /** Default active tab value */\n defaultValue?: string\n /** Tab components (TabList and TabPanels) */\n children: ReactNode\n}\n\n/**\n * Tabs container component for organizing content into tabbed panels.\n */\nexport function Tabs({ defaultValue, children }: TabsProps) {\n const [activeTab, setActiveTab] = useState(defaultValue || \"\")\n\n return (\n <TabsContext.Provider value={{ activeTab, setActiveTab }}>\n <div className=\"ardo-tabs\">{children}</div>\n </TabsContext.Provider>\n )\n}\n\nexport interface TabListProps {\n /** Tab buttons */\n children: ReactNode\n}\n\n/**\n * Container for Tab buttons.\n */\nexport function TabList({ children }: TabListProps) {\n return (\n <div className=\"ardo-tab-list\" role=\"tablist\">\n {children}\n </div>\n )\n}\n\nexport interface TabProps {\n /** Unique value identifying this tab */\n value: string\n /** Tab button label */\n children: ReactNode\n}\n\n/**\n * Individual tab button.\n */\nexport function Tab({ value, children }: TabProps) {\n const { activeTab, setActiveTab } = useTabsContext()\n const isActive = activeTab === value\n\n return (\n <button\n role=\"tab\"\n aria-selected={isActive}\n className={[\"ardo-tab\", isActive && \"active\"].filter(Boolean).join(\" \")}\n onClick={() => setActiveTab(value)}\n >\n {children}\n </button>\n )\n}\n\nexport interface TabPanelProps {\n /** Value matching the corresponding Tab */\n value: string\n /** Panel content */\n children: ReactNode\n}\n\n/**\n * Content panel for a tab.\n */\nexport function TabPanel({ value, children }: TabPanelProps) {\n const { activeTab } = useTabsContext()\n const isActive = activeTab === value\n\n if (!isActive) {\n return null\n }\n\n return (\n <div role=\"tabpanel\" className=\"ardo-tab-panel\">\n {children}\n </div>\n )\n}\n\nexport interface TabPanelsProps {\n /** TabPanel components */\n children: ReactNode\n}\n\n/**\n * Container for TabPanel components.\n */\nexport function TabPanels({ children }: TabPanelsProps) {\n return <div className=\"ardo-tab-panels\">{children}</div>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe,kBAAkC;AAiBjD;AAfT,IAAM,qBAAqB,cAAc,KAAK;AAcvC,SAAS,YAAY,EAAE,SAAS,GAA4B;AACjE,SAAO,oBAAC,sBAAmB,OAAO,MAAO,UAAS;AACpD;AAEO,SAAS,iBAA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E/D,SAAS,iBAAiB;AACxB,QAAM,UAAUC,YAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;AAYO,SAAS,KAAK,EAAE,cAAc,SAAS,GAAc;AAC1D,QAAM,CAAC,WAAW,YAAY,IAAIF,UAAS,gBAAgB,EAAE;AAE7D,SACE,gBAAAG,KAAC,YAAY,UAAZ,EAAqB,OAAO,EAAE,WAAW,aAAa,GACrD,0BAAAA,KAAC,SAAI,WAAU,aAAa,UAAS,GACvC;AAEJ;AAUO,SAAS,QAAQ,EAAE,SAAS,GAAiB;AAClD,SACE,gBAAAA,KAAC,SAAI,WAAU,iBAAgB,MAAK,WACjC,UACH;AAEJ;AAYO,SAAS,IAAI,EAAE,OAAO,SAAS,GAAa;AACjD,QAAM,EAAE,WAAW,aAAa,IAAI,eAAe;AACnD,QAAM,WAAW,cAAc;AAE/B,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,iBAAe;AAAA,MACf,WAAW,CAAC,YAAY,YAAY,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MACtE,SAAS,MAAM,aAAa,KAAK;AAAA,MAEhC;AAAA;AAAA,EACH;AAEJ;AAYO,SAAS,SAAS,EAAE,OAAO,SAAS,GAAkB;AAC3D,QAAM,EAAE,UAAU,IAAI,eAAe;AACrC,QAAM,WAAW,cAAc;AAE/B,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,SACE,gBAAAA,KAAC,SAAI,MAAK,YAAW,WAAU,kBAC5B,UACH;AAEJ;AAUO,SAAS,UAAU,EAAE,SAAS,GAAmB;AACtD,SAAO,gBAAAA,KAAC,SAAI,WAAU,mBAAmB,UAAS;AACpD;","names":["jsx","jsx","icons","jsx","jsxs","useState","jsx","jsxs","useState","jsx","jsxs","useState","createContext","useContext","jsx"]}
@@ -20,6 +20,30 @@ import {
20
20
  createHighlighter
21
21
  } from "shiki";
22
22
  import { visit } from "unist-util-visit";
23
+ var DEFAULT_THEMES = {
24
+ light: "github-light-default",
25
+ dark: "github-dark-default"
26
+ };
27
+ var cachedHighlighter;
28
+ async function highlightCode(code, language, options) {
29
+ const themeConfig = options?.theme ?? DEFAULT_THEMES;
30
+ if (!cachedHighlighter) {
31
+ cachedHighlighter = await createShikiHighlighter({
32
+ theme: themeConfig,
33
+ lineNumbers: false,
34
+ anchor: false,
35
+ toc: { level: [2, 3] }
36
+ });
37
+ }
38
+ if (typeof themeConfig === "string") {
39
+ return cachedHighlighter.codeToHtml(code, { lang: language, theme: themeConfig });
40
+ }
41
+ return cachedHighlighter.codeToHtml(code, {
42
+ lang: language,
43
+ themes: { light: themeConfig.light, dark: themeConfig.dark },
44
+ defaultColor: false
45
+ });
46
+ }
23
47
  async function createShikiHighlighter(config) {
24
48
  const themeConfig = config.theme;
25
49
  const themes = typeof themeConfig === "string" ? [themeConfig] : [themeConfig.light, themeConfig.dark];
@@ -546,6 +570,86 @@ ${entries.join("\n")}
546
570
  };
547
571
  }
548
572
 
573
+ // src/vite/codeblock-plugin.ts
574
+ function outdent(text) {
575
+ const trimmed = text.replace(/^\n+/, "").replace(/\n\s*$/, "");
576
+ const lines = trimmed.split("\n");
577
+ const indent = lines.reduce((min, line) => {
578
+ if (line.trim().length === 0) return min;
579
+ const match = line.match(/^(\s*)/);
580
+ return match ? Math.min(min, match[1].length) : min;
581
+ }, Infinity);
582
+ if (indent === 0 || indent === Infinity) return trimmed;
583
+ return lines.map((line) => line.slice(indent)).join("\n");
584
+ }
585
+ function ardoCodeBlockPlugin(markdownConfig) {
586
+ return {
587
+ name: "ardo:codeblock-highlight",
588
+ enforce: "pre",
589
+ async transform(code, id) {
590
+ if (!/\.[jt]sx$/.test(id)) return;
591
+ if (!code.includes("CodeBlock")) return;
592
+ if (id.includes("node_modules")) return;
593
+ let result = code;
594
+ let offset = 0;
595
+ const propRegex = /<CodeBlock\s+([^>]*?)\/>/g;
596
+ let match;
597
+ while ((match = propRegex.exec(code)) !== null) {
598
+ const fullMatch = match[0];
599
+ const propsStr = match[1];
600
+ const codeMatch = propsStr.match(/\bcode="((?:[^"\\]|\\.)*)"/s) || propsStr.match(/\bcode=\{"((?:[^"\\]|\\.)*)"\}/s);
601
+ if (!codeMatch) continue;
602
+ const langMatch = propsStr.match(/\blanguage="([^"]*)"/) || propsStr.match(/\blanguage=\{"([^"]*)"\}/);
603
+ if (!langMatch) continue;
604
+ if (propsStr.includes("__html")) continue;
605
+ const codeContent = codeMatch[1].replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
606
+ const language = langMatch[1];
607
+ try {
608
+ const html = await highlightCode(codeContent, language, {
609
+ theme: markdownConfig?.theme
610
+ });
611
+ const escapedHtml = JSON.stringify(html);
612
+ const newPropsStr = `__html={${escapedHtml}} ` + propsStr;
613
+ const newFullMatch = fullMatch.replace(propsStr, newPropsStr);
614
+ result = result.slice(0, match.index + offset) + newFullMatch + result.slice(match.index + offset + fullMatch.length);
615
+ offset += newFullMatch.length - fullMatch.length;
616
+ } catch {
617
+ }
618
+ }
619
+ const childrenRegex = /<CodeBlock\s+([^>]*?)>([\s\S]*?)<\/CodeBlock>/g;
620
+ offset = result.length - code.length;
621
+ while ((match = childrenRegex.exec(code)) !== null) {
622
+ const fullMatch = match[0];
623
+ const propsStr = match[1];
624
+ let rawChildren = match[2];
625
+ const langMatch = propsStr.match(/\blanguage="([^"]*)"/) || propsStr.match(/\blanguage=\{"([^"]*)"\}/);
626
+ if (!langMatch) continue;
627
+ if (propsStr.includes("__html")) continue;
628
+ const templateMatch = rawChildren.match(/^\s*\{`([\s\S]*)`\}\s*$/);
629
+ if (templateMatch) {
630
+ rawChildren = templateMatch[1];
631
+ }
632
+ const codeContent = outdent(rawChildren);
633
+ const language = langMatch[1];
634
+ try {
635
+ const html = await highlightCode(codeContent, language, {
636
+ theme: markdownConfig?.theme
637
+ });
638
+ const escapedHtml = JSON.stringify(html);
639
+ const escapedCode = JSON.stringify(codeContent);
640
+ const newTag = `<CodeBlock __html={${escapedHtml}} code={${escapedCode}} ${propsStr} />`;
641
+ result = result.slice(0, match.index + offset) + newTag + result.slice(match.index + offset + fullMatch.length);
642
+ offset += newTag.length - fullMatch.length;
643
+ } catch {
644
+ }
645
+ }
646
+ if (result !== code) {
647
+ return { code: result, map: null };
648
+ }
649
+ }
650
+ };
651
+ }
652
+
549
653
  // src/vite/plugin.ts
550
654
  function findPackageRoot(cwd) {
551
655
  let dir = path2.resolve(cwd);
@@ -803,6 +907,7 @@ export const meta = () => [${metaEntries.join(", ")}];
803
907
  };
804
908
  plugins.unshift(typedocPlugin);
805
909
  }
910
+ plugins.push(ardoCodeBlockPlugin(pressConfig.markdown));
806
911
  const themeConfig = pressConfig.markdown?.theme ?? defaultMarkdownConfig.theme;
807
912
  const hasThemeObject = themeConfig && typeof themeConfig === "object" && "light" in themeConfig;
808
913
  const lineNumbers = pressConfig.markdown?.lineNumbers || false;
@@ -1285,6 +1390,7 @@ function normalizePath(p) {
1285
1390
  }
1286
1391
 
1287
1392
  export {
1393
+ highlightCode,
1288
1394
  createShikiHighlighter,
1289
1395
  ardoRoutesPlugin,
1290
1396
  detectGitHubBasename,
@@ -1297,4 +1403,4 @@ export {
1297
1403
  getPageDataForRoute,
1298
1404
  generateSidebar2 as generateSidebar
1299
1405
  };
1300
- //# sourceMappingURL=chunk-WSEWAHW3.js.map
1406
+ //# sourceMappingURL=chunk-YUGJQYEK.js.map