Skip to content

Commit

Permalink
Update Node + @mdx-js/mdx example
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 24, 2024
1 parent 62a02e7 commit 4e2032d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
11 changes: 6 additions & 5 deletions sandbox-templates/mdx-evaulate-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// You can refresh them in the Dependencies section (left-bottom on CodeSandbox)

import http from 'node:http'
import * as runtime from 'react/jsx-runtime'
import ReactDom from 'react-dom/server'
import {evaluate} from '@mdx-js/mdx'
import {renderToPipeableStream} from 'react-dom/server'
import * as runtime from 'react/jsx-runtime'

// Note: refresh the pane on the right to see changes.

http
.createServer(async function (_, response) {
const content = "Hi <span style={{color: 'tomato'}}>there</span>!"
const {default: Content} = await evaluate(content, runtime)
ReactDom.renderToNodeStream(Content()).pipe(response)
const mdx = "Hi <span style={{color: 'tomato'}}>there</span>!"
const {default: Content} = await evaluate(mdx, runtime)
const {pipe} = renderToPipeableStream(Content({}))
pipe(response)
})
.listen(8080)
19 changes: 9 additions & 10 deletions sandbox-templates/mdx-evaulate-node/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"name": "node-http-server",
"version": "1.0.0",
"dependencies": {
"@mdx-js/mdx": "^3.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"license": "MIT",
"name": "node-http-server",
"private": true,
"type": "module",
"scripts": {
"start": "nodemon index.js"
"start": "node --watch index.js"
},
"dependencies": {
"@mdx-js/mdx": "^2.0.0",
"nodemon": "^2.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
}
"type": "module",
"version": "1.0.0"
}

0 comments on commit 4e2032d

Please sign in to comment.