-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example to parse any block text #416
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments but looks good 👍
async function retrieveBlockChildren(id) { | ||
console.log("Retrieving blocks (async)...") | ||
|
||
const blocks = await notion.blocks.children.list({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include pagination here? We have a helper called iteratePaginatedAPI
included in the SDK 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh cool, thanks! I'll add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added! Thanks for the review. 🙏 Looks like it needs another approval to merge so I re-requested another one.
* add block text example * clean up comments * add embed option * update comment: * pr feeedback: name change, updated switch case, join richtext array without comma * use iteratePaginatedAPI helper to capture all blocks on page
Adds example of how to parse the text from any type of block that is currently supported by the public API. This example includes retrieving the block children for a page (notion.blocks.children.list()) and parsing the text from each block returned. The text is then printed to the command line.
The page used can be set in the .env file, along with the integration key.
This example is not intended to have any "real-word" application other than providing devs with some helpful functions to use in their own Notion apps.
Based on a request to support customers looking for help with this.
Note: I tried to prioritize readability over making it as succinct as possible.