@next-library/theme 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +59 -10
- package/dist/client.js.map +1 -1
- package/dist/components/markdown/markdown-renderer.d.ts +17 -1
- package/dist/components/markdown/markdown-renderer.d.ts.map +1 -1
- package/dist/index.js +60 -11
- package/dist/index.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
- package/src/style.css +55 -3
package/dist/client.js
CHANGED
|
@@ -4714,6 +4714,27 @@ function FolderCards({ nodes }) {
|
|
|
4714
4714
|
node.websitePath
|
|
4715
4715
|
)) });
|
|
4716
4716
|
}
|
|
4717
|
+
function resolveInternalDocHref(href, baseDir, locale) {
|
|
4718
|
+
if (!href || baseDir === void 0 || !locale) return null;
|
|
4719
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("#") || href.startsWith("/")) {
|
|
4720
|
+
return null;
|
|
4721
|
+
}
|
|
4722
|
+
const marker = href.search(/[#?]/);
|
|
4723
|
+
const pathPart = marker === -1 ? href : href.slice(0, marker);
|
|
4724
|
+
const suffix = marker === -1 ? "" : href.slice(marker);
|
|
4725
|
+
if (!/\.md$/i.test(pathPart)) return null;
|
|
4726
|
+
const segments = baseDir.split("/").filter(Boolean);
|
|
4727
|
+
for (const raw of pathPart.split("/")) {
|
|
4728
|
+
if (raw === "" || raw === ".") continue;
|
|
4729
|
+
if (raw === "..") {
|
|
4730
|
+
if (segments.length) segments.pop();
|
|
4731
|
+
continue;
|
|
4732
|
+
}
|
|
4733
|
+
segments.push(raw);
|
|
4734
|
+
}
|
|
4735
|
+
const resolved = segments.join("/").replace(/\/index\.md$/i, "").replace(/\.md$/i, "");
|
|
4736
|
+
return resolved ? `/${locale}/docs/${resolved}${suffix}` : `/${locale}/docs${suffix}`;
|
|
4737
|
+
}
|
|
4717
4738
|
function CodeBlock({ children, ...props }) {
|
|
4718
4739
|
const preRef = useRef(null);
|
|
4719
4740
|
const [copied, setCopied] = useState(false);
|
|
@@ -4740,10 +4761,26 @@ function CodeBlock({ children, ...props }) {
|
|
|
4740
4761
|
/* @__PURE__ */ jsx("pre", { ref: preRef, ...props, children })
|
|
4741
4762
|
] });
|
|
4742
4763
|
}
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4764
|
+
function makeAnchor(baseDir, locale) {
|
|
4765
|
+
return function Anchor({
|
|
4766
|
+
href,
|
|
4767
|
+
children,
|
|
4768
|
+
...props
|
|
4769
|
+
}) {
|
|
4770
|
+
const internal = resolveInternalDocHref(href, baseDir, locale);
|
|
4771
|
+
if (internal) {
|
|
4772
|
+
return /* @__PURE__ */ jsx(Link3, { href: internal, children });
|
|
4773
|
+
}
|
|
4774
|
+
return /* @__PURE__ */ jsx("a", { href, ...props, children });
|
|
4775
|
+
};
|
|
4776
|
+
}
|
|
4777
|
+
function makeComponents(baseDir, locale) {
|
|
4778
|
+
return {
|
|
4779
|
+
h1: () => null,
|
|
4780
|
+
pre: CodeBlock,
|
|
4781
|
+
a: makeAnchor(baseDir, locale)
|
|
4782
|
+
};
|
|
4783
|
+
}
|
|
4747
4784
|
var remarkPlugins = [remarkLint, remarkGfm, remarkFrontmatter];
|
|
4748
4785
|
var rehypePlugins = [
|
|
4749
4786
|
rehypeSanitize,
|
|
@@ -4760,10 +4797,22 @@ var rehypePlugins = [
|
|
|
4760
4797
|
rehypeExternalLinks,
|
|
4761
4798
|
rehypeHighlight
|
|
4762
4799
|
];
|
|
4763
|
-
function Markdown({
|
|
4764
|
-
|
|
4800
|
+
function Markdown({
|
|
4801
|
+
markdown,
|
|
4802
|
+
baseDir,
|
|
4803
|
+
locale
|
|
4804
|
+
}) {
|
|
4805
|
+
return /* @__PURE__ */ jsx(
|
|
4806
|
+
ReactMarkdown,
|
|
4807
|
+
{
|
|
4808
|
+
remarkPlugins,
|
|
4809
|
+
rehypePlugins,
|
|
4810
|
+
components: makeComponents(baseDir, locale),
|
|
4811
|
+
children: markdown
|
|
4812
|
+
}
|
|
4813
|
+
);
|
|
4765
4814
|
}
|
|
4766
|
-
function Tabs({ tabs }) {
|
|
4815
|
+
function Tabs({ tabs, baseDir, locale }) {
|
|
4767
4816
|
const [active, setActive] = useState(0);
|
|
4768
4817
|
return /* @__PURE__ */ jsxs("div", { className: "cl-tabs not-prose", children: [
|
|
4769
4818
|
/* @__PURE__ */ jsx("div", { className: "cl-tabs-list", role: "tablist", children: tabs.map((t, i) => /* @__PURE__ */ jsx(
|
|
@@ -4778,7 +4827,7 @@ function Tabs({ tabs }) {
|
|
|
4778
4827
|
},
|
|
4779
4828
|
i
|
|
4780
4829
|
)) }),
|
|
4781
|
-
/* @__PURE__ */ jsx("div", { className: "cl-tabs-panel prose prose-md max-w-none dark:prose-invert", children: /* @__PURE__ */ jsx(Markdown, { markdown: tabs[active]?.content ?? "" }) })
|
|
4830
|
+
/* @__PURE__ */ jsx("div", { className: "cl-tabs-panel prose prose-md max-w-none dark:prose-invert", children: /* @__PURE__ */ jsx(Markdown, { markdown: tabs[active]?.content ?? "", baseDir, locale }) })
|
|
4782
4831
|
] });
|
|
4783
4832
|
}
|
|
4784
4833
|
function parseSegments(md) {
|
|
@@ -4802,10 +4851,10 @@ function parseTabs(block) {
|
|
|
4802
4851
|
}
|
|
4803
4852
|
return tabs.length ? tabs : [{ title: "Tab", content: block }];
|
|
4804
4853
|
}
|
|
4805
|
-
function MarkdownRenderer({ markdown, className = "" }) {
|
|
4854
|
+
function MarkdownRenderer({ markdown, className = "", baseDir, locale }) {
|
|
4806
4855
|
const segments = markdown.includes("<!-- tabs") ? parseSegments(markdown) : [{ type: "md", content: markdown }];
|
|
4807
4856
|
return /* @__PURE__ */ jsx("article", { className: `cl-content-in prose prose-md max-w-none dark:prose-invert ${className}`, children: segments.map(
|
|
4808
|
-
(s, i) => s.type === "tabs" ? /* @__PURE__ */ jsx(Tabs, { tabs: s.tabs }, i) : /* @__PURE__ */ jsx(Markdown, { markdown: s.content }, i)
|
|
4857
|
+
(s, i) => s.type === "tabs" ? /* @__PURE__ */ jsx(Tabs, { tabs: s.tabs, baseDir, locale }, i) : /* @__PURE__ */ jsx(Markdown, { markdown: s.content, baseDir, locale }, i)
|
|
4809
4858
|
) });
|
|
4810
4859
|
}
|
|
4811
4860
|
function ChatGPTIcon({ className }) {
|