@quietmind/mdx-docs 0.1.0 → 0.1.1
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 +99 -223
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,277 +1,153 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @quietmind/mdx-docs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A React + Vite framework for building MDX-powered documentation sites. Write pages in Markdown with embedded React components, and get a fully-featured site with syntax highlighting, dark/light mode, and responsive navigation out of the box.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Demo:** https://thequietmind.github.io/mdx-docs/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Features
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- MDX pages — write Markdown with embedded React components
|
|
10
|
+
- Syntax highlighting with copy-to-clipboard on code blocks
|
|
11
|
+
- Dark/light mode with system preference detection
|
|
12
|
+
- Responsive sidebar navigation
|
|
13
|
+
- Built on React 19, Material-UI 7, and Vite 6
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Clone the repository:
|
|
15
|
-
|
|
16
|
-
```sh
|
|
17
|
-
git clone https://github.com/ezrafree/quietmind-dev.git && \
|
|
18
|
-
cd quietmind-dev
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Install dependencies:
|
|
15
|
+
## Installation
|
|
22
16
|
|
|
23
17
|
```sh
|
|
24
|
-
|
|
18
|
+
npm install @quietmind/mdx-docs
|
|
25
19
|
```
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
### Peer dependencies
|
|
28
22
|
|
|
29
23
|
```sh
|
|
30
|
-
|
|
24
|
+
npm install react react-dom react-router-dom \
|
|
25
|
+
@emotion/react @emotion/styled \
|
|
26
|
+
@mui/material @mui/icons-material \
|
|
27
|
+
@mdx-js/react @mdx-js/rollup \
|
|
28
|
+
prism-react-renderer prismjs \
|
|
29
|
+
vite @vitejs/plugin-react
|
|
31
30
|
```
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## 📋 Available Scripts
|
|
36
|
-
|
|
37
|
-
| Command | Description |
|
|
38
|
-
|---------|-------------|
|
|
39
|
-
| `yarn dev` | Start development server |
|
|
40
|
-
| `yarn build` | Build for production |
|
|
41
|
-
| `yarn preview` | Preview production build locally |
|
|
42
|
-
| `yarn serve` | Preview production build with network access |
|
|
43
|
-
| `yarn lint` | Run ESLint |
|
|
44
|
-
| `yarn test` | Run tests |
|
|
45
|
-
| `yarn test:watch` | Run tests in watch mode |
|
|
46
|
-
| `yarn test:coverage` | Run tests with coverage |
|
|
47
|
-
| `yarn test:ui` | Run tests with UI |
|
|
48
|
-
| `yarn deploy` | Deploy to GitHub Pages |
|
|
49
|
-
|
|
50
|
-
## 📚 Tech Stack
|
|
51
|
-
|
|
52
|
-
- **Frontend**: React 19, Material-UI 7, Emotion
|
|
53
|
-
- **Build Tool**: Vite 6
|
|
54
|
-
- **Routing**: React Router DOM 7
|
|
55
|
-
- **Documentation**: MDX 3
|
|
56
|
-
- **Testing**: Vitest, Testing Library
|
|
57
|
-
- **Deployment**: GitHub Pages
|
|
58
|
-
|
|
59
|
-
## 📖 Documentation Structure
|
|
32
|
+
## Quick Start
|
|
60
33
|
|
|
61
|
-
###
|
|
34
|
+
### 1. Site structure
|
|
62
35
|
|
|
63
|
-
Create a new MDX file in `src/contents/`:
|
|
64
|
-
|
|
65
|
-
```mdx
|
|
66
|
-
# My New Page
|
|
67
|
-
|
|
68
|
-
This is my new documentation page with **markdown** and React components.
|
|
69
36
|
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
route: "/my-new-page",
|
|
81
|
-
component: MyNewPageMDX,
|
|
82
|
-
},
|
|
83
|
-
];
|
|
37
|
+
my-site/
|
|
38
|
+
├── pages/
|
|
39
|
+
│ └── home.mdx
|
|
40
|
+
├── config/
|
|
41
|
+
│ ├── pages.js
|
|
42
|
+
│ └── site.js
|
|
43
|
+
├── index.html
|
|
44
|
+
├── main.jsx
|
|
45
|
+
├── vite.config.js
|
|
46
|
+
└── package.json
|
|
84
47
|
```
|
|
85
48
|
|
|
86
|
-
###
|
|
87
|
-
|
|
88
|
-
- **Code Blocks**: Syntax highlighting with copy buttons
|
|
89
|
-
- **Inline Code**: Styled inline code snippets
|
|
90
|
-
- **React Components**: Embed any React component directly in MDX
|
|
91
|
-
- **External Links**: Automatically open in new tabs
|
|
92
|
-
|
|
93
|
-
## 🎨 Theming
|
|
94
|
-
|
|
95
|
-
### Customizing Colors
|
|
96
|
-
|
|
97
|
-
Update the theme files to customize the appearance:
|
|
98
|
-
|
|
99
|
-
- **Light Theme**: `src/themes/lightTheme.js`
|
|
100
|
-
- **Dark Theme**: `src/themes/darkTheme.js`
|
|
101
|
-
|
|
102
|
-
Example theme customization:
|
|
49
|
+
### 2. `config/site.js`
|
|
103
50
|
|
|
104
51
|
```js
|
|
105
|
-
export const
|
|
106
|
-
|
|
107
|
-
primary: {
|
|
108
|
-
main: '#1976d2',
|
|
109
|
-
},
|
|
110
|
-
secondary: {
|
|
111
|
-
main: '#dc004e',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
52
|
+
export const site = {
|
|
53
|
+
name: "My Site",
|
|
114
54
|
};
|
|
115
55
|
```
|
|
116
56
|
|
|
117
|
-
###
|
|
118
|
-
|
|
119
|
-
Use the `useTheme` hook to access theme state:
|
|
57
|
+
### 3. `config/pages.js`
|
|
120
58
|
|
|
121
59
|
```js
|
|
122
|
-
import {
|
|
123
|
-
|
|
124
|
-
function MyComponent() {
|
|
125
|
-
const { darkMode, setDarkMode } = useTheme();
|
|
126
|
-
// ...
|
|
127
|
-
}
|
|
128
|
-
```
|
|
60
|
+
import { lazy } from "react";
|
|
129
61
|
|
|
130
|
-
|
|
62
|
+
const HomeMDX = lazy(() => import("@pages/home.mdx"));
|
|
131
63
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
├── config/
|
|
141
|
-
│ └── pages.js # Page configuration
|
|
142
|
-
├── contents/ # MDX documentation files
|
|
143
|
-
│ ├── button.mdx
|
|
144
|
-
│ ├── colors.mdx
|
|
145
|
-
│ ├── home.mdx
|
|
146
|
-
│ └── typography.mdx
|
|
147
|
-
├── hooks/
|
|
148
|
-
│ └── useTheme.js # Theme management hook
|
|
149
|
-
├── themes/ # Material-UI themes
|
|
150
|
-
│ ├── darkTheme.js
|
|
151
|
-
│ ├── lightTheme.js
|
|
152
|
-
│ └── index.js
|
|
153
|
-
└── utils/
|
|
154
|
-
└── navigation.js # Navigation utilities
|
|
64
|
+
export const pages = [
|
|
65
|
+
{
|
|
66
|
+
name: "Home",
|
|
67
|
+
route: "/",
|
|
68
|
+
component: HomeMDX,
|
|
69
|
+
isDefault: true,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
155
72
|
```
|
|
156
73
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
The project includes comprehensive tests with good coverage thresholds:
|
|
74
|
+
### 4. `main.jsx`
|
|
160
75
|
|
|
161
|
-
|
|
162
|
-
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```sh
|
|
168
|
-
# Run all tests
|
|
169
|
-
yarn test
|
|
170
|
-
|
|
171
|
-
# Watch mode
|
|
172
|
-
yarn test:watch
|
|
173
|
-
|
|
174
|
-
# With coverage
|
|
175
|
-
yarn test:coverage
|
|
76
|
+
```js
|
|
77
|
+
import "@quietmind/mdx-docs/index.css";
|
|
78
|
+
import { createApp } from "@quietmind/mdx-docs";
|
|
79
|
+
import { pages } from "./config/pages.js";
|
|
80
|
+
import { site } from "./config/site.js";
|
|
176
81
|
|
|
177
|
-
|
|
178
|
-
yarn test:ui
|
|
82
|
+
createApp({ pages, site });
|
|
179
83
|
```
|
|
180
84
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
### GitHub Pages
|
|
184
|
-
|
|
185
|
-
The project is configured for GitHub Pages deployment:
|
|
85
|
+
### 5. `vite.config.js`
|
|
186
86
|
|
|
187
|
-
|
|
188
|
-
|
|
87
|
+
```js
|
|
88
|
+
import { defineConfig } from "vite";
|
|
89
|
+
import { createMdxDocsConfig } from "@quietmind/mdx-docs/vite";
|
|
189
90
|
|
|
190
|
-
|
|
191
|
-
|
|
91
|
+
export default defineConfig(
|
|
92
|
+
createMdxDocsConfig({ rootDir: import.meta.dirname })
|
|
93
|
+
);
|
|
192
94
|
```
|
|
193
95
|
|
|
194
|
-
###
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
96
|
+
### 6. `index.html`
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<!DOCTYPE html>
|
|
100
|
+
<html lang="en">
|
|
101
|
+
<head>
|
|
102
|
+
<meta charset="UTF-8" />
|
|
103
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
104
|
+
<title>My Site</title>
|
|
105
|
+
</head>
|
|
106
|
+
<body>
|
|
107
|
+
<div id="root"></div>
|
|
108
|
+
<script type="module" src="/main.jsx"></script>
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|
|
203
111
|
```
|
|
204
112
|
|
|
205
|
-
|
|
113
|
+
## Adding Pages
|
|
206
114
|
|
|
207
|
-
|
|
115
|
+
Create an MDX file in `pages/`:
|
|
208
116
|
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
yarn serve
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
This serves the production build and makes it accessible on your local network.
|
|
215
|
-
|
|
216
|
-
#### Option 3: Using a Static File Server
|
|
117
|
+
```mdx
|
|
118
|
+
# Getting Started
|
|
217
119
|
|
|
218
|
-
|
|
120
|
+
This is a documentation page with **markdown** and React components.
|
|
219
121
|
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
# or
|
|
223
|
-
yarn global add serve
|
|
122
|
+
```js
|
|
123
|
+
const hello = "world";
|
|
224
124
|
```
|
|
225
|
-
|
|
226
|
-
Then build and serve:
|
|
227
|
-
|
|
228
|
-
```sh
|
|
229
|
-
yarn build
|
|
230
|
-
serve -s dist -l 3000
|
|
231
125
|
```
|
|
232
126
|
|
|
233
|
-
|
|
127
|
+
Register it in `config/pages.js`:
|
|
234
128
|
|
|
235
|
-
|
|
129
|
+
```js
|
|
130
|
+
const GettingStartedMDX = lazy(() => import("@pages/getting-started.mdx"));
|
|
236
131
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
132
|
+
export const pages = [
|
|
133
|
+
// ...existing pages
|
|
134
|
+
{
|
|
135
|
+
name: "Getting Started",
|
|
136
|
+
route: "/getting-started",
|
|
137
|
+
component: GettingStartedMDX,
|
|
138
|
+
},
|
|
139
|
+
];
|
|
240
140
|
```
|
|
241
141
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
### Vite Configuration
|
|
245
|
-
|
|
246
|
-
The Vite config (`vite.config.js`) includes:
|
|
247
|
-
|
|
248
|
-
- MDX plugin configuration
|
|
249
|
-
- Emotion JSX runtime
|
|
250
|
-
- Dynamic base URL for GitHub Pages
|
|
251
|
-
|
|
252
|
-
### ESLint
|
|
253
|
-
|
|
254
|
-
ESLint is configured with:
|
|
255
|
-
|
|
256
|
-
- React and React Hooks rules
|
|
257
|
-
- Import organization
|
|
258
|
-
- Modern JavaScript standards
|
|
259
|
-
|
|
260
|
-
## 🤝 Contributing
|
|
261
|
-
|
|
262
|
-
1. Fork the repository
|
|
263
|
-
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
|
264
|
-
3. Commit your changes: `git commit -m 'Add amazing feature'`
|
|
265
|
-
4. Push to the branch: `git push origin feature/amazing-feature`
|
|
266
|
-
5. Open a Pull Request
|
|
142
|
+
Pages without `isDefault: true` appear in the sidebar navigation. The page with `isDefault: true` is the fallback/home route.
|
|
267
143
|
|
|
268
|
-
##
|
|
144
|
+
## Tech Stack
|
|
269
145
|
|
|
270
|
-
|
|
146
|
+
- React 19, Material-UI 7, Emotion
|
|
147
|
+
- Vite 6, MDX 3
|
|
148
|
+
- React Router DOM 7
|
|
149
|
+
- Prism React Renderer
|
|
271
150
|
|
|
272
|
-
##
|
|
151
|
+
## License
|
|
273
152
|
|
|
274
|
-
|
|
275
|
-
- [Material-UI](https://mui.com/) for the beautiful component library
|
|
276
|
-
- [Vite](https://vitejs.dev/) for the lightning-fast build tool
|
|
277
|
-
- [Prism React Renderer](https://github.com/FormidableLabs/prism-react-renderer) for syntax highlighting
|
|
153
|
+
MIT
|