File tree Expand file tree Collapse file tree 2 files changed +45
-4
lines changed Expand file tree Collapse file tree 2 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < title > Code Hike in the browser</ title >
5+ < link
6+ rel ="stylesheet "
7+ href ="https://esm.sh/@code-hike/mdx@0.4.0--canary.154.285c03a.0/dist/index.css "
8+ />
9+ </ head >
10+ < body >
11+ < div id ="root "> </ div >
12+
13+ < script type ="module ">
14+ import React from "https://esm.sh/react"
15+ import ReactDOM from "https://esm.sh/react-dom"
16+ import { evaluate } from "https://esm.sh/@mdx-js/mdx?dev"
17+ import * as runtime from "https://esm.sh/react/jsx-runtime.js"
18+
19+ import { remarkCodeHike } from "https://esm.sh/@code-hike/mdx@0.4.0--canary.154.285c03a.0/dist/index.browser.mjs"
20+ import { CH } from "https://esm.sh/@code-hike/mdx@0.4.0--canary.154.285c03a.0/components"
21+ import theme from "https://esm.sh/shiki@0.10.1/themes/nord.json" assert { type : "json " }
22+
23+ const mdx = `# Test
24+
25+ ~~~python hello.py mark=1[22:30]
26+ print("Rendered with Code Hike")
27+ ~~~
28+ `
29+
30+ const { default : Content } = await evaluate ( mdx , {
31+ ...runtime ,
32+ remarkPlugins : [ [ remarkCodeHike , { autoImport : false , theme } ] ] ,
33+ } )
34+
35+ const App = ( ) => {
36+ return React . createElement ( Content , { components : { CH } } )
37+ }
38+
39+ ReactDOM . render ( React . createElement ( App ) , document . getElementById ( "root" ) )
40+ </ script >
41+ </ body >
42+ </ html >
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ export default function makeConfig(commandOptions) {
4848 } ) ,
4949 ] ,
5050 } ,
51- // for the browser esm we need to replace shiki with shiki/dist/shiki .browser.mjs
51+ // for the browser esm we need to replace shiki with shiki/dist/index .browser.mjs
5252 // https://github.com/shikijs/shiki/issues/131#issuecomment-1094281851
5353 {
5454 input : `src/index.tsx` ,
@@ -63,9 +63,8 @@ export default function makeConfig(commandOptions) {
6363 replace ( {
6464 delimiters : [ "" , "" ] ,
6565 values : {
66- '"shiki"' : JSON . stringify (
67- "shiki/dist/index.browser.mjs"
68- ) ,
66+ 'from "shiki"' :
67+ 'from "shiki/dist/index.browser.mjs"' ,
6968 } ,
7069 } ) ,
7170 json ( { compact : true } ) ,
You can’t perform that action at this time.
0 commit comments