Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/konojunya/notion-markdown
Parse the Notion page as a Markdown
https://github.com/konojunya/notion-markdown
markdown notion notion-markdown parser
Last synced: 3 months ago
JSON representation
Parse the Notion page as a Markdown
- Host: GitHub
- URL: https://github.com/konojunya/notion-markdown
- Owner: konojunya
- License: mit
- Created: 2020-05-13T01:10:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T05:47:23.000Z (about 2 years ago)
- Last Synced: 2024-10-25T18:57:55.457Z (3 months ago)
- Topics: markdown, notion, notion-markdown, parser
- Language: TypeScript
- Size: 423 KB
- Stars: 36
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# notion-markdown
Parse the Notion page as a Markdown
## Installation
```bash
$ yarn add notion-markdown
```## Usage
```js
import notion from 'notion-markdown';
import fetch from 'node-fetch';fetch('https://www.notion.so/api/v3/loadPageChunk', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
cookie: `token_v2=`,
},
body: JSON.stringify({
pageId: ,
limit: 50, // notion default setting,
cursor: { stack: [] },
chunkNumber: 0,
verticalColumns: false,
})
}).then(res => res.json()).then(res => {
// Please put the contents of `res.recordMap.block` in the notion function.
console.log(notion(Object.values(res.recordMap.block)));
});
```## API
### `notion`
```typescript
function notion(blocks: Block[]): string;
```The Block has the following structure.
```typescript
type Block = {
role: string;
value: {
id: string;
type: string;
properties?: any;
};
};
```## CHANGELOG
See [CHANGELOG.md](https://github.com/konojunya/notion-markdown/blob/master/CHANGELOG.md).
## Contributing
welcoming your contribution 👏
1. Fork
2. Create a feature branch
3. Run test suite with the `$ yarn test` command and confirm that it passes
4. Commit your changes
5. Rebase your local changes against the `master` branch
6. Create new Pull Request 🎉Bugs, feature requests and comments are more than welcome in the [issues](https://github.com/konojunya/notion-markdown/issues).
### Development scripts
#### `yarn test`
Run Unit test with Jest.
```bash
$ yarn test
```#### `yarn lint`
Run lint with ESLint.
```bash
$ yarn lint
```#### `yarn format`
Run formatting with ESLint (--fix) and Prettier.
```bash
$ yarn format
```### License
[MIT](https://github.com/konojunya/notion-markdown/blob/master/LICENSE)