-
-
Notifications
You must be signed in to change notification settings - Fork 865
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* resolving path to @mdx-js/tag, fix loader options * del peerDep, improve readme * add example
- Loading branch information
1 parent
c0013d4
commit ad25c6b
Showing
12 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
logs | ||
*.log | ||
npm-debug.log* | ||
.DS_Store | ||
|
||
coverage | ||
node_modules | ||
build | ||
public/static | ||
.env.*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"private": true, | ||
"name": "mdx-razzle", | ||
"scripts": { | ||
"start": "razzle start", | ||
"build": "razzle build", | ||
"test": "razzle test --env=jsdom", | ||
"start:prod": "NODE_ENV=production node build/server.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.15.2", | ||
"razzle": "^2.4.0", | ||
"razzle-plugin-mdx": "^2.4.0", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"remark-emoji": "^2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
const emoji = require('remark-emoji'); | ||
|
||
module.exports = { | ||
plugins: [ | ||
{ | ||
name: 'mdx', | ||
options: { | ||
mdPlugins: [emoji], | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# MDX + Razzle | ||
|
||
``` | ||
npm install | ||
npm start | ||
``` | ||
|
||
[See documentation](https://mdxjs.com/getting-started/razzle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React from 'react'; | ||
import Doc from './example.md'; | ||
|
||
export default () => <Doc />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import { hydrate } from 'react-dom'; | ||
import App from './App'; | ||
|
||
hydrate(<App />, document.getElementById('root')); | ||
|
||
if (module.hot) { | ||
module.hot.accept(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# :wave: Hello, world! | ||
|
||
This is MDX! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import express from 'express'; | ||
import app from './server'; | ||
|
||
if (module.hot) { | ||
module.hot.accept('./server', function() { | ||
console.log('🔁 HMR Reloading `./server`...'); | ||
}); | ||
console.info('✅ Server-side HMR Enabled!'); | ||
} | ||
|
||
const port = process.env.PORT || 3000; | ||
|
||
export default express() | ||
.use((req, res) => app.handle(req, res)) | ||
.listen(port, function(err) { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
console.log(`> Started on port ${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import App from './App'; | ||
import React from 'react'; | ||
import express from 'express'; | ||
import { renderToString } from 'react-dom/server'; | ||
|
||
const assets = require(process.env.RAZZLE_ASSETS_MANIFEST); | ||
|
||
const server = express(); | ||
|
||
server | ||
.disable('x-powered-by') | ||
.use(express.static(process.env.RAZZLE_PUBLIC_DIR)) | ||
.get('/*', (req, res) => { | ||
const markup = renderToString(<App />); | ||
res.send( | ||
// prettier-ignore | ||
`<!doctype html> | ||
<html lang=""> | ||
<head> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta charSet='utf-8' /> | ||
<title>Welcome to Razzle</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
${ | ||
assets.client.css | ||
? `<link rel="stylesheet" href="${assets.client.css}">` | ||
: '' | ||
} | ||
</head> | ||
<body> | ||
<div id="root">${markup}</div> | ||
<script src="${assets.client.js}" defer crossorigin></script> | ||
</body> | ||
</html>` | ||
); | ||
}); | ||
|
||
export default server; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters