Skip to content

Commit

Permalink
Add markdown-in-js example (#3410)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Dec 7, 2017
1 parent 0350750 commit 51f120e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/with-markdown/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["next/babel"],
"plugins": ["markdown-in-js/babel"]
}
16 changes: 16 additions & 0 deletions examples/with-markdown/package.json
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions examples/with-markdown/pages/index.js
Original file line number Diff line number Diff line change
@@ -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 changes: 40 additions & 0 deletions examples/with-markdown/readme.md
Original file line number Diff line number Diff line change
@@ -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*.

0 comments on commit 51f120e

Please sign in to comment.