forked from code-hike/codehike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (41 loc) · 1.24 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Code Hike in the browser</title>
<link
rel="stylesheet"
href="https://esm.sh/@code-hike/[email protected]/dist/index.css"
/>
</head>
<body>
<div id="root"></div>
<script type="module">
import React from "https://esm.sh/react"
import ReactDOM from "https://esm.sh/react-dom"
import { evaluate } from "https://esm.sh/@mdx-js/mdx?bundle"
import * as runtime from "https://esm.sh/react/jsx-runtime.js"
import { remarkCodeHike } from "https://esm.sh/@code-hike/[email protected]/dist/index.browser.mjs"
import { CH } from "https://esm.sh/@code-hike/[email protected]/components"
const mdx = `# Test
<CH.Code>
~~~python hello.py mark=1[22:30]
print("Rendered with Code Hike")
~~~
~~~js hello.js mark=1[23:36]
console.log("Rendered with Code Hike")
~~~
</CH.Code>
`
const { default: Content } = await evaluate(mdx, {
...runtime,
remarkPlugins: [
[remarkCodeHike, { autoImport: false, theme: "dracula" }],
],
})
const App = () => {
return React.createElement(Content, { components: { CH } })
}
ReactDOM.render(React.createElement(App), document.getElementById("root"))
</script>
</body>
</html>