https://github.com/charliewilco/draft-as-markdown
https://github.com/charliewilco/draft-as-markdown
draft-js markdown microservice
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/charliewilco/draft-as-markdown
- Owner: charliewilco
- Created: 2017-09-24T02:45:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-25T06:35:57.000Z (over 8 years ago)
- Last Synced: 2025-11-30T19:46:33.372Z (6 months ago)
- Topics: draft-js, markdown, microservice
- Language: JavaScript
- Homepage: https://draft-to-markdown.now.sh/
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# draft-to-markdown
`draft-to-markdown.now.sh/` is the micro service version of the really awesome [markdown-draft-js](https://github.com/Rosey/markdown-draft-js) module. Submitting a `POST` request to this endpoint will send back a stream of a blob of your `EditorState` as a formatted markdown file with simple front matter.
## Usage
**POST** __`/`__ render markdown text
```javascript
{
content: '', // from draft-js
title: '' // string
}
```
## Example
```javascript
import { saveAs } from 'file-saver'
import { EditorState, convertToRaw } from 'draft-js'
const body = {
title: 'Something Detailed Post'
content: convertToRaw(EditorState.getCurrentContent())
}
const exportMD = async (body: Object) => {
const res = await fetch('https://draft-to-markdown.now.sh/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
const blob = await res.blob()
saveAs(blob, `${body.title.replace(/\s+/g, '-').toLowerCase()}.md`)
}
```