mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add markdown-in-js example (#3410)
This commit is contained in:
parent
03507501cd
commit
51f120ec70
4
examples/with-markdown/.babelrc
Normal file
4
examples/with-markdown/.babelrc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"presets": ["next/babel"],
|
||||
"plugins": ["markdown-in-js/babel"]
|
||||
}
|
16
examples/with-markdown/package.json
Normal file
16
examples/with-markdown/package.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "with-markdown",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "next",
|
||||
"build": "next build",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"markdown-in-js": "1.1.3",
|
||||
"next": "latest",
|
||||
"react": "^16.0.0",
|
||||
"react-dom": "^16.0.0"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
9
examples/with-markdown/pages/index.js
Normal file
9
examples/with-markdown/pages/index.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import markdown from 'markdown-in-js'
|
||||
|
||||
// For more advanced use cases see https://github.com/threepointone/markdown-in-js
|
||||
|
||||
export default () => <div>{markdown`
|
||||
## This is a title
|
||||
|
||||
This is a paragraph
|
||||
`}</div>
|
40
examples/with-markdown/readme.md
Normal file
40
examples/with-markdown/readme.md
Normal file
|
@ -0,0 +1,40 @@
|
|||
[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/with-markdown)
|
||||
|
||||
# With Markdown example
|
||||
|
||||
## How to use
|
||||
|
||||
### Using `create-next-app`
|
||||
|
||||
Download [`create-next-app`](https://github.com/segmentio/create-next-app) to bootstrap the example:
|
||||
|
||||
```
|
||||
npm i -g create-next-app
|
||||
create-next-app --example with-markdown with-markdown
|
||||
```
|
||||
|
||||
### Download manually
|
||||
|
||||
Download the example [or clone the repo](https://github.com/zeit/next.js):
|
||||
|
||||
```bash
|
||||
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-markdown
|
||||
cd with-markdown
|
||||
```
|
||||
|
||||
Install it and run:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
|
||||
|
||||
```bash
|
||||
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*.
|
Loading…
Reference in a new issue