@rasenganjs/mdx 1.0.1 → 1.0.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/README.md +7 -11
- package/lib/components/codeblock.d.ts +15 -0
- package/lib/components/codeblock.js +63 -0
- package/lib/components/codeblock.js.map +1 -0
- package/lib/components/heading.d.ts +2 -0
- package/lib/components/heading.js +40 -0
- package/lib/components/heading.js.map +1 -0
- package/lib/components/index.d.ts +2 -25
- package/lib/components/index.js +12 -78
- package/lib/components/index.js.map +1 -1
- package/lib/components/table.d.ts +3 -0
- package/lib/components/table.js +5 -0
- package/lib/components/table.js.map +1 -0
- package/lib/index.d.ts +3 -26
- package/lib/index.js +3 -5
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +25 -1
- package/lib/utils/extract-toc.d.ts +1 -0
- package/lib/utils/extract-toc.js +12 -0
- package/lib/utils/extract-toc.js.map +1 -0
- package/lib/utils/index.d.ts +1 -3
- package/lib/utils/index.js +1 -4
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mark-to-html.d.ts +1 -0
- package/lib/utils/mark-to-html.js +15 -0
- package/lib/utils/mark-to-html.js.map +1 -0
- package/lib/utils/plugin.d.ts +2 -2
- package/lib/utils/plugin.js +19 -6
- package/lib/utils/plugin.js.map +1 -1
- package/package.json +59 -52
- package/lib/utils/generate-page.d.ts +0 -10
- package/lib/utils/generate-page.js +0 -18
- package/lib/utils/generate-page.js.map +0 -1
- package/lib/utils/globals.d.ts +0 -20
- package/lib/utils/globals.js +0 -30
- package/lib/utils/globals.js.map +0 -1
- package/lib/utils/polyfills.d.ts +0 -29
- package/lib/utils/polyfills.js +0 -120
- package/lib/utils/polyfills.js.map +0 -1
- package/lib/utils/test.d.ts +0 -1
- package/lib/utils/test.js +0 -6
- package/lib/utils/test.js.map +0 -1
- package/src/components/index.tsx +0 -219
- package/src/index.ts +0 -15
- package/src/types/index.ts +0 -15
- package/src/utils/create-filter.ts +0 -26
- package/src/utils/generate-page.tsx +0 -24
- package/src/utils/globals.ts +0 -32
- package/src/utils/index.ts +0 -6
- package/src/utils/plugin.ts +0 -83
- package/src/utils/polyfills.ts +0 -120
- package/src/utils/test.js +0 -7
package/package.json
CHANGED
|
@@ -1,54 +1,61 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
2
|
+
"name": "@rasenganjs/mdx",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.3",
|
|
5
|
+
"description": "RasenganJS plugin for MDX support",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./lib/index.js",
|
|
11
|
+
"require": "./lib/index.js",
|
|
12
|
+
"types": "./lib/types/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "dilane3",
|
|
17
|
+
"email": "komboudilane125@gmail.com",
|
|
18
|
+
"url": "https://dilane3.com",
|
|
19
|
+
"twitter": "https://twitter.com/dilanekombou",
|
|
20
|
+
"github": "https://github.com/dilane3"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/rasengan-dev/rasengan-mdx-plugin.git",
|
|
25
|
+
"issues": "https://github.com/rasengan-dev/rasengan-mdx-plugin/issues"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build:clean": "rm -rf ./lib",
|
|
30
|
+
"build": "npm run build:clean && tsc",
|
|
31
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
32
|
+
"pack": "npm pack --pack-destination ./release",
|
|
33
|
+
"deploy": "npm publish --access public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/micromatch": "^4.0.7",
|
|
37
|
+
"@types/node": "^22.7.4",
|
|
38
|
+
"@types/react": "^18.3.11",
|
|
39
|
+
"@types/react-dom": "^18.3.1",
|
|
40
|
+
"typescript": "^5.2.2"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@mdx-js/rollup": "^3.0.1",
|
|
44
|
+
"gray-matter": "^4.0.3",
|
|
45
|
+
"micromatch": "^4.0.7",
|
|
46
|
+
"path-browserify": "^1.0.1",
|
|
47
|
+
"rehype-pretty-code": "^0.14.0",
|
|
48
|
+
"rehype-stringify": "^10.0.1",
|
|
49
|
+
"remark": "^15.0.1",
|
|
50
|
+
"remark-gfm": "^4.0.0",
|
|
51
|
+
"remark-parse": "^11.0.0",
|
|
52
|
+
"remark-rehype": "^11.1.1",
|
|
53
|
+
"remark-toc": "^9.0.0",
|
|
54
|
+
"unified": "^11.0.5"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"rasengan": "*",
|
|
58
|
+
"react": "^18.3.*",
|
|
59
|
+
"react-dom": "^18.3.*"
|
|
60
|
+
}
|
|
54
61
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type PageComponent } from "rasengan";
|
|
2
|
-
import { MDXPageComponent } from "../types/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Generates a React component from an MDXPageComponent.
|
|
5
|
-
*
|
|
6
|
-
* @param MDXPage - The MDXPageComponent to generate the React component from.
|
|
7
|
-
* @param className - An optional CSS class name to apply to the MDXRenderer component.
|
|
8
|
-
* @returns A React component that renders the MDXPage content using the MDXRenderer.
|
|
9
|
-
*/
|
|
10
|
-
export default function generatePage(MDXPage: MDXPageComponent, className?: string): PageComponent;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { MDXRenderer } from "../components/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Generates a React component from an MDXPageComponent.
|
|
5
|
-
*
|
|
6
|
-
* @param MDXPage - The MDXPageComponent to generate the React component from.
|
|
7
|
-
* @param className - An optional CSS class name to apply to the MDXRenderer component.
|
|
8
|
-
* @returns A React component that renders the MDXPage content using the MDXRenderer.
|
|
9
|
-
*/
|
|
10
|
-
export default function generatePage(MDXPage, className = "") {
|
|
11
|
-
const Page = () => {
|
|
12
|
-
return _jsx(MDXRenderer, { className: className, children: MDXPage });
|
|
13
|
-
};
|
|
14
|
-
Page.path = MDXPage.metadata.path;
|
|
15
|
-
Page.metadata = MDXPage.metadata.metadata;
|
|
16
|
-
return Page;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=generate-page.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-page.js","sourceRoot":"","sources":["../../src/utils/generate-page.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CACnC,OAAyB,EACzB,SAAS,GAAG,EAAE;IAEd,MAAM,IAAI,GAAkB,GAAG,EAAE;QAChC,OAAO,KAAC,WAAW,IAAC,SAAS,EAAE,SAAS,YAAG,OAAO,GAAe,CAAC;IACnE,CAAC,CAAC;IAEF,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IAClC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAE1C,OAAO,IAAI,CAAC;AACb,CAAC"}
|
package/lib/utils/globals.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Provides a Vite plugin that polyfills the `process` and `Buffer` global variables for the browser.
|
|
4
|
-
* This is necessary for certain libraries that expect these global variables to be available.
|
|
5
|
-
* The plugin is applied during the build phase of the Vite build process.
|
|
6
|
-
*/
|
|
7
|
-
export default function globals(): {
|
|
8
|
-
name: string;
|
|
9
|
-
config: (config: any, env: any) => {
|
|
10
|
-
define: {
|
|
11
|
-
process: NodeJS.Process;
|
|
12
|
-
};
|
|
13
|
-
build: {
|
|
14
|
-
rollupOptions: {
|
|
15
|
-
plugins: import("rollup").Plugin<any>[];
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
apply: string;
|
|
20
|
-
};
|
package/lib/utils/globals.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import inject from "@rollup/plugin-inject";
|
|
2
|
-
/**
|
|
3
|
-
* Provides a Vite plugin that polyfills the `process` and `Buffer` global variables for the browser.
|
|
4
|
-
* This is necessary for certain libraries that expect these global variables to be available.
|
|
5
|
-
* The plugin is applied during the build phase of the Vite build process.
|
|
6
|
-
*/
|
|
7
|
-
export default function globals() {
|
|
8
|
-
return {
|
|
9
|
-
name: "vite-plugin-rasengan-global-polyfill",
|
|
10
|
-
config: function config(config, env) {
|
|
11
|
-
// test if we are on the browser
|
|
12
|
-
return {
|
|
13
|
-
define: {
|
|
14
|
-
process: process,
|
|
15
|
-
},
|
|
16
|
-
build: {
|
|
17
|
-
rollupOptions: {
|
|
18
|
-
plugins: [
|
|
19
|
-
inject({
|
|
20
|
-
Buffer: ["buffer", "Buffer"],
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
apply: "build",
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=globals.js.map
|
package/lib/utils/globals.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/utils/globals.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO;IAC9B,OAAO;QACN,IAAI,EAAE,sCAAsC;QAC5C,MAAM,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG;YAClC,gCAAgC;YAChC,OAAO;gBACN,MAAM,EAAE;oBACP,OAAO,EAAE,OAAO;iBAChB;gBAED,KAAK,EAAE;oBACN,aAAa,EAAE;wBACd,OAAO,EAAE;4BACR,MAAM,CAAC;gCACN,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;6BAC5B,CAAC;yBACF;qBACD;iBACD;aACD,CAAC;QACH,CAAC;QAED,KAAK,EAAE,OAAO;KACd,CAAC;AACH,CAAC"}
|
package/lib/utils/polyfills.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* A Vite plugin that provides polyfills for Node.js modules and APIs when running in a browser environment.
|
|
4
|
-
* This plugin is designed to work with the Vite bundler and helps ensure compatibility with Node.js-based code
|
|
5
|
-
* that is being used in a browser context.
|
|
6
|
-
*
|
|
7
|
-
* The plugin configures Vite's resolver to map various Node.js modules and APIs to their browser-compatible
|
|
8
|
-
* counterparts, allowing the code to run seamlessly in the browser without requiring changes to the original
|
|
9
|
-
* Node.js-based implementation.
|
|
10
|
-
*
|
|
11
|
-
* This plugin is particularly useful when working with libraries or frameworks that rely on Node.js-specific
|
|
12
|
-
* functionality, such as the `process` object or various built-in modules like `fs`, `crypto`, and `http`.
|
|
13
|
-
*/
|
|
14
|
-
export default function polyfill(): {
|
|
15
|
-
name: string;
|
|
16
|
-
config: (config: any, env: any) => {
|
|
17
|
-
define: {
|
|
18
|
-
"process.env": NodeJS.ProcessEnv;
|
|
19
|
-
};
|
|
20
|
-
resolve: {
|
|
21
|
-
alias: {
|
|
22
|
-
find: string;
|
|
23
|
-
replacement: string;
|
|
24
|
-
}[];
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
enforce: string;
|
|
28
|
-
apply: string;
|
|
29
|
-
};
|
package/lib/utils/polyfills.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A Vite plugin that provides polyfills for Node.js modules and APIs when running in a browser environment.
|
|
3
|
-
* This plugin is designed to work with the Vite bundler and helps ensure compatibility with Node.js-based code
|
|
4
|
-
* that is being used in a browser context.
|
|
5
|
-
*
|
|
6
|
-
* The plugin configures Vite's resolver to map various Node.js modules and APIs to their browser-compatible
|
|
7
|
-
* counterparts, allowing the code to run seamlessly in the browser without requiring changes to the original
|
|
8
|
-
* Node.js-based implementation.
|
|
9
|
-
*
|
|
10
|
-
* This plugin is particularly useful when working with libraries or frameworks that rely on Node.js-specific
|
|
11
|
-
* functionality, such as the `process` object or various built-in modules like `fs`, `crypto`, and `http`.
|
|
12
|
-
*/
|
|
13
|
-
export default function polyfill() {
|
|
14
|
-
return {
|
|
15
|
-
name: "vite-plugin-rasengan-node-polyfill",
|
|
16
|
-
config: function config(config, env) {
|
|
17
|
-
// test if we are on the browser
|
|
18
|
-
return {
|
|
19
|
-
define: {
|
|
20
|
-
"process.env": process.env,
|
|
21
|
-
},
|
|
22
|
-
resolve: {
|
|
23
|
-
alias: [
|
|
24
|
-
// {
|
|
25
|
-
// find: "assert",
|
|
26
|
-
// replacement: "assert",
|
|
27
|
-
// },
|
|
28
|
-
// {
|
|
29
|
-
// find: "buffer",
|
|
30
|
-
// replacement: "buffer/",
|
|
31
|
-
// },
|
|
32
|
-
// {
|
|
33
|
-
// find: "process",
|
|
34
|
-
// replacement: "process/browser.js",
|
|
35
|
-
// },
|
|
36
|
-
// {
|
|
37
|
-
// find: "console",
|
|
38
|
-
// replacement: "console-browserify",
|
|
39
|
-
// },
|
|
40
|
-
{
|
|
41
|
-
find: "fs",
|
|
42
|
-
replacement: "browserify-fs",
|
|
43
|
-
},
|
|
44
|
-
// {
|
|
45
|
-
// find: "crypto",
|
|
46
|
-
// replacement: "crypto-browserify",
|
|
47
|
-
// },
|
|
48
|
-
// {
|
|
49
|
-
// find: "domain",
|
|
50
|
-
// replacement: "domain-browser",
|
|
51
|
-
// },
|
|
52
|
-
// {
|
|
53
|
-
// find: "events",
|
|
54
|
-
// replacement: "events",
|
|
55
|
-
// },
|
|
56
|
-
// {
|
|
57
|
-
// find: "http",
|
|
58
|
-
// replacement: "stream-http",
|
|
59
|
-
// },
|
|
60
|
-
// {
|
|
61
|
-
// find: "https",
|
|
62
|
-
// replacement: "https-browserify",
|
|
63
|
-
// },
|
|
64
|
-
// {
|
|
65
|
-
// find: "path",
|
|
66
|
-
// replacement: "path-browserify",
|
|
67
|
-
// },
|
|
68
|
-
// {
|
|
69
|
-
// find: "punycode",
|
|
70
|
-
// replacement: "punycode",
|
|
71
|
-
// },
|
|
72
|
-
// {
|
|
73
|
-
// find: "querystring",
|
|
74
|
-
// replacement: "querystring-es3",
|
|
75
|
-
// },
|
|
76
|
-
// {
|
|
77
|
-
// find: "stream",
|
|
78
|
-
// replacement: "stream-browserify",
|
|
79
|
-
// },
|
|
80
|
-
// {
|
|
81
|
-
// find: "string_decoder",
|
|
82
|
-
// replacement: "string_decoder",
|
|
83
|
-
// },
|
|
84
|
-
// {
|
|
85
|
-
// find: "sys",
|
|
86
|
-
// replacement: "util",
|
|
87
|
-
// },
|
|
88
|
-
// {
|
|
89
|
-
// find: "timers",
|
|
90
|
-
// replacement: "timers-browserify",
|
|
91
|
-
// },
|
|
92
|
-
// {
|
|
93
|
-
// find: "tty",
|
|
94
|
-
// replacement: "tty-browserify",
|
|
95
|
-
// },
|
|
96
|
-
// {
|
|
97
|
-
// find: "url",
|
|
98
|
-
// replacement: "url",
|
|
99
|
-
// },
|
|
100
|
-
// {
|
|
101
|
-
// find: "util",
|
|
102
|
-
// replacement: "util",
|
|
103
|
-
// },
|
|
104
|
-
// {
|
|
105
|
-
// find: "vm",
|
|
106
|
-
// replacement: "vm-browserify",
|
|
107
|
-
// },
|
|
108
|
-
// {
|
|
109
|
-
// find: "zlib",
|
|
110
|
-
// replacement: "browserify-zlib",
|
|
111
|
-
// },
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
enforce: "pre",
|
|
117
|
-
apply: "build",
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=polyfills.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../../src/utils/polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ;IAC/B,OAAO;QACN,IAAI,EAAE,oCAAoC;QAC1C,MAAM,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG;YAClC,gCAAgC;YAChC,OAAO;gBACN,MAAM,EAAE;oBACP,aAAa,EAAE,OAAO,CAAC,GAAG;iBAC1B;gBAED,OAAO,EAAE;oBACR,KAAK,EAAE;wBACN,IAAI;wBACJ,mBAAmB;wBACnB,0BAA0B;wBAC1B,KAAK;wBACL,IAAI;wBACJ,mBAAmB;wBACnB,2BAA2B;wBAC3B,KAAK;wBACL,IAAI;wBACJ,oBAAoB;wBACpB,sCAAsC;wBACtC,KAAK;wBACL,IAAI;wBACJ,oBAAoB;wBACpB,sCAAsC;wBACtC,KAAK;wBACL;4BACC,IAAI,EAAE,IAAI;4BACV,WAAW,EAAE,eAAe;yBAC5B;wBACD,IAAI;wBACJ,mBAAmB;wBACnB,qCAAqC;wBACrC,KAAK;wBACL,IAAI;wBACJ,mBAAmB;wBACnB,kCAAkC;wBAClC,KAAK;wBACL,IAAI;wBACJ,mBAAmB;wBACnB,0BAA0B;wBAC1B,KAAK;wBACL,IAAI;wBACJ,iBAAiB;wBACjB,+BAA+B;wBAC/B,KAAK;wBACL,IAAI;wBACJ,kBAAkB;wBAClB,oCAAoC;wBACpC,KAAK;wBACL,IAAI;wBACJ,iBAAiB;wBACjB,mCAAmC;wBACnC,KAAK;wBACL,IAAI;wBACJ,qBAAqB;wBACrB,4BAA4B;wBAC5B,KAAK;wBACL,IAAI;wBACJ,wBAAwB;wBACxB,mCAAmC;wBACnC,KAAK;wBACL,IAAI;wBACJ,mBAAmB;wBACnB,qCAAqC;wBACrC,KAAK;wBACL,IAAI;wBACJ,2BAA2B;wBAC3B,kCAAkC;wBAClC,KAAK;wBACL,IAAI;wBACJ,gBAAgB;wBAChB,wBAAwB;wBACxB,KAAK;wBACL,IAAI;wBACJ,mBAAmB;wBACnB,qCAAqC;wBACrC,KAAK;wBACL,IAAI;wBACJ,gBAAgB;wBAChB,kCAAkC;wBAClC,KAAK;wBACL,IAAI;wBACJ,gBAAgB;wBAChB,uBAAuB;wBACvB,KAAK;wBACL,IAAI;wBACJ,iBAAiB;wBACjB,wBAAwB;wBACxB,KAAK;wBACL,IAAI;wBACJ,eAAe;wBACf,iCAAiC;wBACjC,KAAK;wBACL,IAAI;wBACJ,iBAAiB;wBACjB,mCAAmC;wBACnC,KAAK;qBACL;iBACD;aACD,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO;KACd,CAAC;AACH,CAAC"}
|
package/lib/utils/test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/utils/test.js
DELETED
package/lib/utils/test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/utils/test.js"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAElD,OAAO,CAAC,GAAG,CAAC;IACV,IAAI,EAAE,OAAO,CAAC,wGAAwG,CAAC;CACxH,CAAC,CAAA"}
|
package/src/components/index.tsx
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { themes, Highlight } from "prism-react-renderer";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { MDXPageComponent } from "../types/index.js";
|
|
4
|
-
|
|
5
|
-
type ComponentWithTextChildrenProps = {
|
|
6
|
-
children: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
type MDXRendererProps = {
|
|
10
|
-
children: MDXPageComponent;
|
|
11
|
-
className?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type CodeBlockProps = ComponentWithTextChildrenProps & {
|
|
15
|
-
className?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A React component that renders a code block with syntax highlighting and a copy button.
|
|
21
|
-
*
|
|
22
|
-
* The component uses the `prism-react-renderer` library to provide syntax highlighting for the code block.
|
|
23
|
-
* It also includes a copy button that allows the user to copy the code to their clipboard.
|
|
24
|
-
*
|
|
25
|
-
* @param {object} props - The component props.
|
|
26
|
-
* @param {string} props.children - The code content to be displayed in the code block.
|
|
27
|
-
* @param {string} [props.className] - The CSS class name to apply to the code block.
|
|
28
|
-
* @returns {React.ReactElement} - The rendered code block component.
|
|
29
|
-
*/
|
|
30
|
-
const CodeBlock = ({ children, className = "" }: CodeBlockProps): React.ReactElement => {
|
|
31
|
-
const language = className.replace(/language-/, "");
|
|
32
|
-
|
|
33
|
-
if (!language) {
|
|
34
|
-
return <SimpleBlock>{children}</SimpleBlock>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Highlight
|
|
39
|
-
theme={themes.oneDark}
|
|
40
|
-
code={children.trim()}
|
|
41
|
-
language={language}
|
|
42
|
-
>
|
|
43
|
-
{({ className, tokens, getLineProps, getTokenProps }: any) => {
|
|
44
|
-
const [copied, setCopied] = React.useState(false);
|
|
45
|
-
|
|
46
|
-
React.useEffect(() => {
|
|
47
|
-
/**
|
|
48
|
-
* Sets the `copied` state to `false` after 2 seconds, effectively hiding the "copied" indicator.
|
|
49
|
-
* This function is called after the user's clipboard is updated with the code content.
|
|
50
|
-
*/
|
|
51
|
-
const timer = setTimeout(() => {
|
|
52
|
-
setCopied(false);
|
|
53
|
-
}, 2000);
|
|
54
|
-
|
|
55
|
-
return () => clearTimeout(timer);
|
|
56
|
-
}, [copied]);
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Copies the trimmed text content of the `children` prop to the user's clipboard.
|
|
60
|
-
* This function is called when the "Copy" button is clicked in the code block component.
|
|
61
|
-
* It sets the `copied` state to `true` for 2 seconds to display a "copied" indicator.
|
|
62
|
-
*/
|
|
63
|
-
const handleCopy = () => {
|
|
64
|
-
navigator.clipboard.writeText(children.trim());
|
|
65
|
-
setCopied(true);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<pre
|
|
70
|
-
className={className}
|
|
71
|
-
style={{
|
|
72
|
-
color: "#fff",
|
|
73
|
-
backgroundColor: "#1d2529",
|
|
74
|
-
borderRadius: "20px",
|
|
75
|
-
overflow: "hidden",
|
|
76
|
-
padding: "0px",
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
79
|
-
<div
|
|
80
|
-
style={{
|
|
81
|
-
width: "100%",
|
|
82
|
-
height: "50px",
|
|
83
|
-
backgroundColor: "#28373f",
|
|
84
|
-
display: "flex",
|
|
85
|
-
justifyContent: "space-between",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
paddingLeft: "20px",
|
|
88
|
-
paddingRight: "20px",
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
<span>Filename</span>
|
|
92
|
-
|
|
93
|
-
<button className='copy-button' onClick={handleCopy}>
|
|
94
|
-
{copied ? (
|
|
95
|
-
<svg
|
|
96
|
-
xmlns='http://www.w3.org/2000/svg'
|
|
97
|
-
viewBox='0 0 24 24'
|
|
98
|
-
width='24'
|
|
99
|
-
height='24'
|
|
100
|
-
color='#f0f0f0'
|
|
101
|
-
fill='none'
|
|
102
|
-
>
|
|
103
|
-
<path
|
|
104
|
-
d='M22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12Z'
|
|
105
|
-
stroke='currentColor'
|
|
106
|
-
strokeWidth='1.5'
|
|
107
|
-
/>
|
|
108
|
-
<path
|
|
109
|
-
d='M8 12.5L10.5 15L16 9'
|
|
110
|
-
stroke='currentColor'
|
|
111
|
-
strokeWidth='1.5'
|
|
112
|
-
strokeLinecap='round'
|
|
113
|
-
strokeLinejoin='round'
|
|
114
|
-
/>
|
|
115
|
-
</svg>
|
|
116
|
-
) : (
|
|
117
|
-
<svg
|
|
118
|
-
xmlns='http://www.w3.org/2000/svg'
|
|
119
|
-
viewBox='0 0 24 24'
|
|
120
|
-
width='24'
|
|
121
|
-
height='24'
|
|
122
|
-
color='#f0f0f0'
|
|
123
|
-
fill='none'
|
|
124
|
-
>
|
|
125
|
-
<path
|
|
126
|
-
d='M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z'
|
|
127
|
-
stroke='currentColor'
|
|
128
|
-
strokeWidth='1.5'
|
|
129
|
-
strokeLinecap='round'
|
|
130
|
-
strokeLinejoin='round'
|
|
131
|
-
/>
|
|
132
|
-
<path
|
|
133
|
-
d='M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999'
|
|
134
|
-
stroke='currentColor'
|
|
135
|
-
strokeWidth='1.5'
|
|
136
|
-
strokeLinecap='round'
|
|
137
|
-
strokeLinejoin='round'
|
|
138
|
-
/>
|
|
139
|
-
</svg>
|
|
140
|
-
)}
|
|
141
|
-
</button>
|
|
142
|
-
</div>
|
|
143
|
-
|
|
144
|
-
<div
|
|
145
|
-
style={{
|
|
146
|
-
padding: "20px",
|
|
147
|
-
fontSize: "14px",
|
|
148
|
-
}}
|
|
149
|
-
>
|
|
150
|
-
<code>
|
|
151
|
-
{tokens.map((line: any, i: number) => (
|
|
152
|
-
<div key={i} {...getLineProps({ line })}>
|
|
153
|
-
<span
|
|
154
|
-
style={{
|
|
155
|
-
opacity: 0.6,
|
|
156
|
-
marginRight: "5px",
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
159
|
-
{i + 1}
|
|
160
|
-
</span>
|
|
161
|
-
<span> </span>
|
|
162
|
-
{line.map((token: any, key: number) => (
|
|
163
|
-
<span key={key} {...getTokenProps({ token })} />
|
|
164
|
-
))}
|
|
165
|
-
</div>
|
|
166
|
-
))}
|
|
167
|
-
</code>
|
|
168
|
-
</div>
|
|
169
|
-
</pre>
|
|
170
|
-
);
|
|
171
|
-
}}
|
|
172
|
-
</Highlight>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const SimpleBlock = ({ children }: ComponentWithTextChildrenProps): React.ReactElement => {
|
|
177
|
-
return (
|
|
178
|
-
<span
|
|
179
|
-
className="simple-block"
|
|
180
|
-
style={{
|
|
181
|
-
fontSize: "14px",
|
|
182
|
-
borderRadius: "5px",
|
|
183
|
-
paddingLeft: "3.6px",
|
|
184
|
-
paddingRight: "3.6px",
|
|
185
|
-
paddingTop: "2px",
|
|
186
|
-
paddingBottom: "2px",
|
|
187
|
-
marginInline: "0px",
|
|
188
|
-
backgroundColor: "#f7f7f7",
|
|
189
|
-
border: "1px solid #f0f0f0",
|
|
190
|
-
}}
|
|
191
|
-
>{children}</span>
|
|
192
|
-
);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Renders an MDX content component with a custom code block component.
|
|
197
|
-
*
|
|
198
|
-
* @param {MDXRendererProps} props - The props for the MDX renderer.
|
|
199
|
-
* @param {React.ReactNode} props.children - The MDX content to render.
|
|
200
|
-
* @param {string} [props.className] - An optional CSS class name to apply to the rendered section.
|
|
201
|
-
* @returns {React.ReactElement} - The rendered MDX content with the custom code block component.
|
|
202
|
-
*/
|
|
203
|
-
const MDXRenderer = ({ children: MDXContent, className }: MDXRendererProps): React.ReactElement => {
|
|
204
|
-
return (
|
|
205
|
-
<section className={"rasengan-markdown-body " + className}>
|
|
206
|
-
<MDXContent
|
|
207
|
-
components={{
|
|
208
|
-
code: CodeBlock,
|
|
209
|
-
}}
|
|
210
|
-
/>
|
|
211
|
-
</section>
|
|
212
|
-
);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
export {
|
|
216
|
-
MDXRenderer,
|
|
217
|
-
CodeBlock,
|
|
218
|
-
SimpleBlock
|
|
219
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* License: MIT
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2024 Dilane Kombou
|
|
5
|
-
*
|
|
6
|
-
* This package is inspired by @mdx-js/rollup to provide a custom implement of the MDX plugin for RasenganJs.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export * from './types/index.js';
|
|
10
|
-
import { plugin, generatePage, globalsPolyfill } from "./utils/index.js";
|
|
11
|
-
|
|
12
|
-
export default function() {
|
|
13
|
-
return [plugin(), globalsPolyfill()];
|
|
14
|
-
}
|
|
15
|
-
export { generatePage };
|
package/src/types/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {type Metadata } from "rasengan";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A React functional component that represents an MDX page.
|
|
5
|
-
*
|
|
6
|
-
* The `MDXPageComponent` type extends the `React.FC<ReactComponentProps>` type, which means it is a React functional component that accepts the standard props for a React component.
|
|
7
|
-
*
|
|
8
|
-
* The `MDXPageComponent` type also has an optional `metadata` property of type `Metadata`, which can be used to store metadata about the page.
|
|
9
|
-
*/
|
|
10
|
-
export type MDXPageComponent = React.FC<any> & {
|
|
11
|
-
metadata?: {
|
|
12
|
-
path: string;
|
|
13
|
-
metadata: Metadata;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import micromatch from 'micromatch';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a filter function that can be used to filter a list of IDs based on include and exclude patterns.
|
|
5
|
-
*
|
|
6
|
-
* @param include - A string or array of strings representing the patterns to include.
|
|
7
|
-
* @param exclude - A string or array of strings representing the patterns to exclude.
|
|
8
|
-
* @returns A function that takes an ID string and returns `true` if the ID should be included, `false` otherwise.
|
|
9
|
-
*/
|
|
10
|
-
export default function createFilter(
|
|
11
|
-
include: string,
|
|
12
|
-
exclude?: string
|
|
13
|
-
) {
|
|
14
|
-
return function (id: string) {
|
|
15
|
-
if (typeof id !== "string") return false;
|
|
16
|
-
|
|
17
|
-
const matcher = micromatch.matcher(include);
|
|
18
|
-
|
|
19
|
-
if (exclude) {
|
|
20
|
-
const excluder = micromatch.matcher(exclude);
|
|
21
|
-
return matcher(id) && !excluder(id);
|
|
22
|
-
} else {
|
|
23
|
-
return matcher(id);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|