Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update with-markdown example #4839

Merged
merged 1 commit into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions examples/with-markdown/.babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion examples/with-markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ now

## The idea behind the example

This example shows the most basic idea behind implementing [markdown-in-js](https://github.com/threepointone/markdown-in-js), a library that allows you to write markdown that transpiles to React components *at build time*.
This example shows how to integrate an [MDX](https://github.com/mdx-js/mdx) which is a _"JSX in Markdown loader, parser, and renderer for ambitious projects"_.
19 changes: 19 additions & 0 deletions examples/with-markdown/md/markdown.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Other from './other.mdx'

# Hello, world `awesome` :smile_cat:

<Other components={components} />

```jsx
<Other />
```

Here's a paragraph

https://c8r.imgix.net/028ab8c85da415103cb3b1eb/johno.png

Here's a table

| Test | Table |
| :--- | :---- |
| Col1 | Col2 |
3 changes: 3 additions & 0 deletions examples/with-markdown/md/other.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Other `awesome`

file
15 changes: 15 additions & 0 deletions examples/with-markdown/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const images = require('remark-images')
const emoji = require('remark-emoji')

const withMDX = require('@zeit/next-mdx')({
options: {
mdPlugins: [
images,
emoji
]
}
})

module.exports = withMDX({
pageExtensions: ['js', 'jsx', 'mdx']
})
7 changes: 5 additions & 2 deletions examples/with-markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
"start": "next start"
},
"dependencies": {
"markdown-in-js": "^1.1.4",
"@mdx-js/mdx": "0.15.0-0",
"@zeit/next-mdx": "1.1.0",
"next": "latest",
"react": "^16.0.0",
"react-dom": "^16.0.0"
"react-dom": "^16.0.0",
"remark-emoji": "2.0.1",
"remark-images": "0.8.1"
},
"license": "ISC"
}
1 change: 1 addition & 0 deletions examples/with-markdown/pages/hello.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Hello, world! :smiley:
14 changes: 7 additions & 7 deletions examples/with-markdown/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import markdown from 'markdown-in-js'
import React from 'react'
import Document from '../md/markdown.mdx'

// For more advanced use cases see https://github.com/threepointone/markdown-in-js
const H1 = props => <h1 style={{ color: 'tomato' }} {...props} />
const InlineCode = props => <code id='codes' style={{ color: 'purple' }} {...props} />
const Code = props => <code id='codes' style={{ fontWeight: 600 }} {...props} />
const Pre = props => <pre id='codes' style={{ color: 'red' }} {...props} />

export default () => <div>{markdown`
## This is a title

This is a paragraph
`}</div>
export default () => <Document components={{ h1: H1, pre: Pre, code: Code, inlineCode: InlineCode }} />