1
0
Fork 0
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:
Tim Neutkens 2017-12-06 16:59:32 -08:00 committed by Tim Neutkens
parent 03507501cd
commit 51f120ec70
4 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,4 @@
{
"presets": ["next/babel"],
"plugins": ["markdown-in-js/babel"]
}

View 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"
}

View 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>

View 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*.