Skip to content

Commit

Permalink
✨ Add mdx example
Browse files Browse the repository at this point in the history
  • Loading branch information
amoutonbrady committed Jan 3, 2022
1 parent 3a249f3 commit 988e065
Show file tree
Hide file tree
Showing 7 changed files with 1,100 additions and 39 deletions.
23 changes: 23 additions & 0 deletions playground/components/counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, createSignal } from 'solid-js';

const Counter: Component = () => {
const style = { padding: '8px', color: 'white', background: 'black', borderRadius: '4px' };

const [click, setClick] = createSignal(0);
const increment = () => setClick((click) => click + 1);
const decrement = () => setClick((click) => click - 1);

return (
<>
<button onClick={decrement} style={style}>
-1
</button>
<span>{click()}</span>
<button onClick={increment} style={style}>
+1
</button>
</>
);
};

export default Counter;
5 changes: 5 additions & 0 deletions playground/hello.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Counter from "./components/counter";

# This is MDX woo

<Counter />
3 changes: 3 additions & 0 deletions playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type { RouteDefinition } from 'solid-app-router';

import test from '@@/test.txt?raw';
import Home from '@/index';
// @ts-ignore
import Hello from './hello.mdx';

const json = await fetch('https://jsonplaceholder.typicode.com/todos/1').then((response) =>
response.json(),
Expand Down Expand Up @@ -38,6 +40,7 @@ const App = () => {
<hr />
<Route />
<button onClick={() => setCount(count() + 1)}>{count()}</button>
<Hello />
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@mdx-js/mdx": "^2.0.0-rc.2",
"vite": "^2.7.10",
"vite-plugin-solid": "link:.."
},
"dependencies": {
"solid-app-router": "^0.1.14",
"solid-js": "^1.2.6",
"solid-mdx": "^0.0.5",
"solid-meta": "^0.27.3",
"solid-utils": "^0.8.1"
}
Expand Down
Loading

0 comments on commit 988e065

Please sign in to comment.