@quietmind/mdx-docs 0.1.16 → 0.1.17
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/package.json +3 -1
- package/src/vite.config.helper.js +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quietmind/mdx-docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://mdxdocs.com",
|
|
6
6
|
"exports": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"react": "^19.1.0",
|
|
42
42
|
"react-dom": "^19.1.0",
|
|
43
43
|
"react-router-dom": "^7.6.2",
|
|
44
|
+
"remark-gfm": "^4.0.1",
|
|
44
45
|
"vite": "^6.4.1"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"react": "^19.1.0",
|
|
73
74
|
"react-dom": "^19.1.0",
|
|
74
75
|
"react-router-dom": "^7.6.2",
|
|
76
|
+
"remark-gfm": "^4.0.1",
|
|
75
77
|
"vite": "^6.4.1",
|
|
76
78
|
"vitest": "^3.2.4"
|
|
77
79
|
},
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
1
2
|
import mdx from "@mdx-js/rollup";
|
|
2
3
|
import react from "@vitejs/plugin-react";
|
|
4
|
+
import { resolve } from "path";
|
|
3
5
|
import { fileURLToPath } from "url";
|
|
6
|
+
import remarkGfm from "remark-gfm";
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Rehype plugin that removes <p> wrappers MDX generates around text children
|
|
@@ -49,10 +52,30 @@ export function rehypeUnwrapJsxParagraphs() {
|
|
|
49
52
|
* createMdxDocsConfig({ rootDir: import.meta.dirname })
|
|
50
53
|
* );
|
|
51
54
|
*/
|
|
55
|
+
const VIRTUAL_404_ID = "virtual:mdx-docs/404";
|
|
56
|
+
const RESOLVED_VIRTUAL_404_ID = "\0" + VIRTUAL_404_ID;
|
|
57
|
+
|
|
52
58
|
export function createMdxDocsConfig({ rootDir, base = "/", site = {} } = {}) {
|
|
59
|
+
const custom404Path = resolve(rootDir, "pages/404.mdx");
|
|
60
|
+
const hasCustom404 = existsSync(custom404Path);
|
|
61
|
+
|
|
53
62
|
return {
|
|
54
63
|
base,
|
|
55
64
|
plugins: [
|
|
65
|
+
{
|
|
66
|
+
name: "mdx-docs-404",
|
|
67
|
+
resolveId(id) {
|
|
68
|
+
if (id === VIRTUAL_404_ID) return RESOLVED_VIRTUAL_404_ID;
|
|
69
|
+
},
|
|
70
|
+
load(id) {
|
|
71
|
+
if (id === RESOLVED_VIRTUAL_404_ID) {
|
|
72
|
+
if (hasCustom404) {
|
|
73
|
+
return `export { default } from "@pages/404.mdx";`;
|
|
74
|
+
}
|
|
75
|
+
return `export { NotFound as default } from "@quietmind/mdx-docs";`;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
},
|
|
56
79
|
{
|
|
57
80
|
name: "html-site-config",
|
|
58
81
|
transformIndexHtml: (html) =>
|
|
@@ -64,6 +87,7 @@ export function createMdxDocsConfig({ rootDir, base = "/", site = {} } = {}) {
|
|
|
64
87
|
mdx({
|
|
65
88
|
jsxImportSource: "@emotion/react",
|
|
66
89
|
providerImportSource: "@mdx-js/react",
|
|
90
|
+
remarkPlugins: [remarkGfm],
|
|
67
91
|
rehypePlugins: [rehypeUnwrapJsxParagraphs],
|
|
68
92
|
}),
|
|
69
93
|
],
|