fumadocs-core 15.3.2 → 15.3.3
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/mdx-plugins/index.d.ts +10 -2
- package/dist/mdx-plugins/index.js +107 -42
- package/package.json +10 -10
|
@@ -112,7 +112,15 @@ interface RehypeTocOptions {
|
|
|
112
112
|
}
|
|
113
113
|
declare function rehypeToc(this: Processor, { exportToc }?: RehypeTocOptions): Transformer<Root, Root>;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
interface RemarkCodeTabOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Parse MDX in tab values
|
|
118
|
+
*
|
|
119
|
+
* @defaultValue false
|
|
120
|
+
*/
|
|
121
|
+
parseMdx?: boolean;
|
|
122
|
+
}
|
|
123
|
+
declare function remarkCodeTab(this: Processor, options?: RemarkCodeTabOptions): Transformer<Root$1, Root$1>;
|
|
116
124
|
|
|
117
125
|
interface RemarkStepsOptions {
|
|
118
126
|
/**
|
|
@@ -133,4 +141,4 @@ interface RemarkStepsOptions {
|
|
|
133
141
|
*/
|
|
134
142
|
declare function remarkSteps({ steps, step, }?: RemarkStepsOptions): Transformer<Root$1, Root$1>;
|
|
135
143
|
|
|
136
|
-
export { type CodeBlockIcon, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type RemarkImageOptions, type RemarkStepsOptions, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkImage, remarkSteps, transformerIcon, transformerTab };
|
|
144
|
+
export { type CodeBlockIcon, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type RemarkCodeTabOptions, type RemarkImageOptions, type RemarkStepsOptions, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkImage, remarkSteps, transformerIcon, transformerTab };
|
|
@@ -301,7 +301,7 @@ function transformerTab() {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
// src/mdx-plugins/remark-image.ts
|
|
304
|
-
import * as path from "
|
|
304
|
+
import * as path from "path";
|
|
305
305
|
import { visit } from "unist-util-visit";
|
|
306
306
|
import { imageSize } from "image-size";
|
|
307
307
|
import { imageSizeFromFile } from "image-size/fromFile";
|
|
@@ -761,8 +761,40 @@ function rehypeToc({ exportToc = true } = {}) {
|
|
|
761
761
|
// src/mdx-plugins/remark-code-tab.ts
|
|
762
762
|
import { visit as visit5 } from "unist-util-visit";
|
|
763
763
|
var TabRegex = /tab="(.+?)"/;
|
|
764
|
-
function
|
|
765
|
-
|
|
764
|
+
function remarkCodeTab(options = {}) {
|
|
765
|
+
return (tree) => {
|
|
766
|
+
visit5(tree, (node) => {
|
|
767
|
+
if (!("children" in node)) return;
|
|
768
|
+
if (node.type === "mdxJsxFlowElement" && node.name === "Tabs") return;
|
|
769
|
+
let start = -1;
|
|
770
|
+
let i = 0;
|
|
771
|
+
while (i < node.children.length) {
|
|
772
|
+
const child = node.children[i];
|
|
773
|
+
const isSwitcher = child.type === "code" && child.meta && child.meta.match(TabRegex);
|
|
774
|
+
if (isSwitcher && start === -1) {
|
|
775
|
+
start = i;
|
|
776
|
+
}
|
|
777
|
+
const isLast = i === node.children.length - 1;
|
|
778
|
+
if (start !== -1 && (isLast || !isSwitcher)) {
|
|
779
|
+
const end = isSwitcher ? i + 1 : i;
|
|
780
|
+
const targets = node.children.slice(start, end);
|
|
781
|
+
node.children.splice(
|
|
782
|
+
start,
|
|
783
|
+
end - start,
|
|
784
|
+
options.parseMdx ? toTabMdx(this, targets) : toTab(targets)
|
|
785
|
+
);
|
|
786
|
+
if (isLast) break;
|
|
787
|
+
i = start + 1;
|
|
788
|
+
start = -1;
|
|
789
|
+
} else {
|
|
790
|
+
i++;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function processTabValue(nodes) {
|
|
797
|
+
return nodes.map((node, i) => {
|
|
766
798
|
let title = `Tab ${i + 1}`;
|
|
767
799
|
node.meta = node.meta?.replace(TabRegex, (_, value) => {
|
|
768
800
|
title = value;
|
|
@@ -770,16 +802,9 @@ function toTab(nodes) {
|
|
|
770
802
|
});
|
|
771
803
|
return title;
|
|
772
804
|
});
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
type: "ArrayExpression",
|
|
777
|
-
elements: names.map((name) => ({
|
|
778
|
-
type: "Literal",
|
|
779
|
-
value: name
|
|
780
|
-
}))
|
|
781
|
-
}
|
|
782
|
-
};
|
|
805
|
+
}
|
|
806
|
+
function toTab(nodes) {
|
|
807
|
+
const names = processTabValue(nodes);
|
|
783
808
|
return {
|
|
784
809
|
type: "mdxJsxFlowElement",
|
|
785
810
|
name: "Tabs",
|
|
@@ -789,12 +814,24 @@ function toTab(nodes) {
|
|
|
789
814
|
name: "items",
|
|
790
815
|
value: {
|
|
791
816
|
type: "mdxJsxAttributeValueExpression",
|
|
817
|
+
value: names.join(", "),
|
|
792
818
|
data: {
|
|
793
819
|
estree: {
|
|
794
820
|
type: "Program",
|
|
795
821
|
sourceType: "module",
|
|
796
822
|
comments: [],
|
|
797
|
-
body: [
|
|
823
|
+
body: [
|
|
824
|
+
{
|
|
825
|
+
type: "ExpressionStatement",
|
|
826
|
+
expression: {
|
|
827
|
+
type: "ArrayExpression",
|
|
828
|
+
elements: names.map((name) => ({
|
|
829
|
+
type: "Literal",
|
|
830
|
+
value: name
|
|
831
|
+
}))
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
]
|
|
798
835
|
}
|
|
799
836
|
}
|
|
800
837
|
}
|
|
@@ -816,35 +853,63 @@ function toTab(nodes) {
|
|
|
816
853
|
})
|
|
817
854
|
};
|
|
818
855
|
}
|
|
819
|
-
function
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
end - start,
|
|
839
|
-
toTab(targets)
|
|
840
|
-
);
|
|
841
|
-
if (isLast) break;
|
|
842
|
-
i = start;
|
|
843
|
-
start = -1;
|
|
844
|
-
}
|
|
845
|
-
i++;
|
|
856
|
+
function toTabMdx(processor, nodes) {
|
|
857
|
+
const names = processTabValue(nodes);
|
|
858
|
+
function inline(node) {
|
|
859
|
+
if (node.type === "root") {
|
|
860
|
+
node.children = node.children.flatMap((child) => {
|
|
861
|
+
if (child.type === "paragraph") return child.children;
|
|
862
|
+
return child;
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
return node;
|
|
866
|
+
}
|
|
867
|
+
return {
|
|
868
|
+
type: "mdxJsxFlowElement",
|
|
869
|
+
name: "Tabs",
|
|
870
|
+
attributes: [
|
|
871
|
+
{
|
|
872
|
+
type: "mdxJsxAttribute",
|
|
873
|
+
name: "defaultValue",
|
|
874
|
+
value: names[0]
|
|
846
875
|
}
|
|
847
|
-
|
|
876
|
+
],
|
|
877
|
+
children: [
|
|
878
|
+
{
|
|
879
|
+
type: "mdxJsxFlowElement",
|
|
880
|
+
name: "TabsList",
|
|
881
|
+
attributes: [],
|
|
882
|
+
children: names.map((name) => ({
|
|
883
|
+
type: "mdxJsxFlowElement",
|
|
884
|
+
name: "TabsTrigger",
|
|
885
|
+
attributes: [
|
|
886
|
+
{
|
|
887
|
+
type: "mdxJsxAttribute",
|
|
888
|
+
name: "value",
|
|
889
|
+
value: name
|
|
890
|
+
}
|
|
891
|
+
],
|
|
892
|
+
children: [
|
|
893
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed
|
|
894
|
+
inline(processor.parse(name))
|
|
895
|
+
]
|
|
896
|
+
}))
|
|
897
|
+
},
|
|
898
|
+
...nodes.map(
|
|
899
|
+
(node, i) => ({
|
|
900
|
+
type: "mdxJsxFlowElement",
|
|
901
|
+
name: "TabsContent",
|
|
902
|
+
attributes: [
|
|
903
|
+
{
|
|
904
|
+
type: "mdxJsxAttribute",
|
|
905
|
+
name: "value",
|
|
906
|
+
value: names[i]
|
|
907
|
+
}
|
|
908
|
+
],
|
|
909
|
+
children: [node]
|
|
910
|
+
})
|
|
911
|
+
)
|
|
912
|
+
]
|
|
848
913
|
};
|
|
849
914
|
}
|
|
850
915
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "15.3.
|
|
3
|
+
"version": "15.3.3",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@formatjs/intl-localematcher": "^0.6.1",
|
|
81
81
|
"@orama/orama": "^3.1.6",
|
|
82
|
-
"@shikijs/rehype": "^3.4.
|
|
83
|
-
"@shikijs/transformers": "^3.4.
|
|
82
|
+
"@shikijs/rehype": "^3.4.2",
|
|
83
|
+
"@shikijs/transformers": "^3.4.2",
|
|
84
84
|
"github-slugger": "^2.0.0",
|
|
85
85
|
"hast-util-to-estree": "^3.1.3",
|
|
86
86
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
@@ -90,26 +90,26 @@
|
|
|
90
90
|
"remark": "^15.0.0",
|
|
91
91
|
"remark-gfm": "^4.0.1",
|
|
92
92
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
93
|
-
"shiki": "^3.4.
|
|
93
|
+
"shiki": "^3.4.2",
|
|
94
94
|
"unist-util-visit": "^5.0.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
97
|
"@algolia/client-search": "4.24.0",
|
|
98
98
|
"@mdx-js/mdx": "^3.1.0",
|
|
99
99
|
"@oramacloud/client": "^2.1.4",
|
|
100
|
-
"@tanstack/react-router": "^1.
|
|
100
|
+
"@tanstack/react-router": "^1.120.3",
|
|
101
101
|
"@types/estree-jsx": "^1.0.5",
|
|
102
102
|
"@types/hast": "^3.0.4",
|
|
103
103
|
"@types/mdast": "^4.0.3",
|
|
104
104
|
"@types/negotiator": "^0.6.3",
|
|
105
|
-
"@types/node": "22.15.
|
|
106
|
-
"@types/react": "^19.1.
|
|
107
|
-
"@types/react-dom": "^19.1.
|
|
105
|
+
"@types/node": "22.15.18",
|
|
106
|
+
"@types/react": "^19.1.4",
|
|
107
|
+
"@types/react-dom": "^19.1.5",
|
|
108
108
|
"algoliasearch": "4.24.0",
|
|
109
109
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
110
110
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
111
|
-
"next": "^15.3.
|
|
112
|
-
"react-router": "^7.
|
|
111
|
+
"next": "^15.3.2",
|
|
112
|
+
"react-router": "^7.6.0",
|
|
113
113
|
"remark-mdx": "^3.1.0",
|
|
114
114
|
"remark-rehype": "^11.1.2",
|
|
115
115
|
"typescript": "^5.8.3",
|