notion-markdown
v0.0.1
Published
Parse the Notion page as a Markdownts-jest
Downloads
2
Maintainers
Readme
notion-markdown
Parse the Notion page as a Markdown
Installation
$ yarn add notion-markdown
Usage
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=<your cookie>`,
},
body: JSON.stringify({
pageId: <your blog page id(if the id is 32 characters, it is still not normalized)>,
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
function notion(blocks: Block[]): string;
The Block has the following structure.
type Block = {
role: string;
value: {
id: string;
type: string;
properties?: any;
};
};
CHANGELOG
See CHANGELOG.md.
Contributing
welcoming your contribution 👏
- Fork
- Create a feature branch
- Run test suite with the
$ yarn test
command and confirm that it passes - Commit your changes
- Rebase your local changes against the
master
branch - Create new Pull Request 🎉
Bugs, feature requests and comments are more than welcome in the issues.
Development scripts
yarn test
Run Unit test with Jest.
$ yarn test
yarn lint
Run lint with ESLint.
$ yarn lint
yarn format
Run formatting with ESLint (--fix) and Prettier.
$ yarn format