Skip to content

Commit 3d17f62

Browse files
committed
✨ Add mdx example
1 parent 130cfec commit 3d17f62

File tree

7 files changed

+1100
-39
lines changed

7 files changed

+1100
-39
lines changed

playground/components/counter.tsx

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Component, createSignal } from 'solid-js';
2+
3+
const Counter: Component = () => {
4+
const style = { padding: '8px', color: 'white', background: 'black', borderRadius: '4px' };
5+
6+
const [click, setClick] = createSignal(0);
7+
const increment = () => setClick((click) => click + 1);
8+
const decrement = () => setClick((click) => click - 1);
9+
10+
return (
11+
<>
12+
<button onClick={decrement} style={style}>
13+
-1
14+
</button>
15+
<span>{click()}</span>
16+
<button onClick={increment} style={style}>
17+
+1
18+
</button>
19+
</>
20+
);
21+
};
22+
23+
export default Counter;

playground/hello.mdx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Counter from "./components/counter";
2+
3+
# This is MDX woo
4+
5+
<Counter />

playground/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { RouteDefinition } from 'solid-app-router';
66

77
import test from '@@/test.txt?raw';
88
import Home from '@/index';
9+
// @ts-ignore
10+
import Hello from './hello.mdx';
911

1012
const json = await fetch('https://jsonplaceholder.typicode.com/todos/1').then((response) =>
1113
response.json(),
@@ -38,6 +40,7 @@ const App = () => {
3840
<hr />
3941
<Route />
4042
<button onClick={() => setCount(count() + 1)}>{count()}</button>
43+
<Hello />
4144
</>
4245
);
4346
};

playground/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
"devDependencies": {
1111
"@babel/core": "^7.16.7",
1212
"@babel/plugin-syntax-top-level-await": "^7.14.5",
13+
"@mdx-js/mdx": "^2.0.0-rc.2",
1314
"vite": "^2.7.10",
1415
"vite-plugin-solid": "link:.."
1516
},
1617
"dependencies": {
1718
"solid-app-router": "^0.1.14",
1819
"solid-js": "^1.2.6",
20+
"solid-mdx": "^0.0.5",
1921
"solid-meta": "^0.27.3",
2022
"solid-utils": "^0.8.1"
2123
}

0 commit comments

Comments
 (0)