File tree Expand file tree Collapse file tree
packages/razzle-plugin-mdx Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ logs
2+ * .log
3+ npm-debug.log *
4+ .DS_Store
5+
6+ coverage
7+ node_modules
8+ build
9+ public /static
10+ .env. * .local
Original file line number Diff line number Diff line change 1+ {
2+ "private" : true ,
3+ "name" : " mdx-razzle" ,
4+ "scripts" : {
5+ "start" : " razzle start" ,
6+ "build" : " razzle build" ,
7+ "test" : " razzle test --env=jsdom" ,
8+ "start:prod" : " NODE_ENV=production node build/server.js"
9+ },
10+ "dependencies" : {
11+ "express" : " ^4.15.2" ,
12+ "razzle" : " ^2.4.0" ,
13+ "razzle-plugin-mdx" : " ^2.4.0" ,
14+ "react" : " ^16.0.0" ,
15+ "react-dom" : " ^16.0.0" ,
16+ "remark-emoji" : " ^2.0.1"
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const emoji = require ( 'remark-emoji' ) ;
4+
5+ module . exports = {
6+ plugins : [
7+ {
8+ name : 'mdx' ,
9+ options : {
10+ mdPlugins : [ emoji ] ,
11+ } ,
12+ } ,
13+ ] ,
14+ } ;
Original file line number Diff line number Diff line change 1+ # MDX + Razzle
2+
3+ ```
4+ npm install
5+ npm start
6+ ```
7+
8+ [ See documentation] ( https://mdxjs.com/getting-started/razzle )
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import Doc from './example.md' ;
3+
4+ export default ( ) => < Doc /> ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { hydrate } from 'react-dom' ;
3+ import App from './App' ;
4+
5+ hydrate ( < App /> , document . getElementById ( 'root' ) ) ;
6+
7+ if ( module . hot ) {
8+ module . hot . accept ( ) ;
9+ }
Original file line number Diff line number Diff line change 1+ # :wave : Hello, world!
2+
3+ This is MDX!
Original file line number Diff line number Diff line change 1+ import express from 'express' ;
2+ import app from './server' ;
3+
4+ if ( module . hot ) {
5+ module . hot . accept ( './server' , function ( ) {
6+ console . log ( '🔁 HMR Reloading `./server`...' ) ;
7+ } ) ;
8+ console . info ( '✅ Server-side HMR Enabled!' ) ;
9+ }
10+
11+ const port = process . env . PORT || 3000 ;
12+
13+ export default express ( )
14+ . use ( ( req , res ) => app . handle ( req , res ) )
15+ . listen ( port , function ( err ) {
16+ if ( err ) {
17+ console . error ( err ) ;
18+ return ;
19+ }
20+ console . log ( `> Started on port ${ port } ` ) ;
21+ } ) ;
Original file line number Diff line number Diff line change 1+ import App from './App' ;
2+ import React from 'react' ;
3+ import express from 'express' ;
4+ import { renderToString } from 'react-dom/server' ;
5+
6+ const assets = require ( process . env . RAZZLE_ASSETS_MANIFEST ) ;
7+
8+ const server = express ( ) ;
9+
10+ server
11+ . disable ( 'x-powered-by' )
12+ . use ( express . static ( process . env . RAZZLE_PUBLIC_DIR ) )
13+ . get ( '/*' , ( req , res ) => {
14+ const markup = renderToString ( < App /> ) ;
15+ res . send (
16+ // prettier-ignore
17+ `<!doctype html>
18+ <html lang="">
19+ <head>
20+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
21+ <meta charSet='utf-8' />
22+ <title>Welcome to Razzle</title>
23+ <meta name="viewport" content="width=device-width, initial-scale=1">
24+ ${
25+ assets . client . css
26+ ? `<link rel="stylesheet" href="${ assets . client . css } ">`
27+ : ''
28+ }
29+ </head>
30+ <body>
31+ <div id="root">${ markup } </div>
32+ <script src="${ assets . client . js } " defer crossorigin></script>
33+ </body>
34+ </html>`
35+ ) ;
36+ } ) ;
37+
38+ export default server ;
Original file line number Diff line number Diff line change @@ -5,13 +5,13 @@ This package contains a plugin for using mdx with Razzle
55## Usage in Razzle Projects
66
77```
8- npm i razzle-plugin-mdx @mdx-js/tag
8+ npm i razzle-plugin-mdx
99```
1010
1111or
1212
1313```
14- yarn add razzle-plugin-mdx @mdx-js/tag
14+ yarn add razzle-plugin-mdx
1515```
1616
1717### Using the plugin with the default options
You can’t perform that action at this time.
0 commit comments