Parse the Notion page as a Markdown
$ yarn add notion-markdown
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)));
});
function notion(blocks: Block[]): string;
The Block has the following structure.
type Block = {
role: string;
value: {
id: string;
type: string;
properties?: any;
};
};
See CHANGELOG.md.
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.
Run Unit test with Jest.
$ yarn test
Run lint with ESLint.
$ yarn lint
Run formatting with ESLint (--fix) and Prettier.
$ yarn format