Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 2.26 KB

README.md

File metadata and controls

52 lines (38 loc) · 2.26 KB

notionpub

This utility uploads markdown files to a Notion workspace.

🚧 It is currently a frankenstein wrapper of md2notion and notion-py which are two abandoned projects.

md2notion implements a markdown to Notion block mapping -- but the published code is outdated and now incompatible with the public Notion API.

notion-py is a python client that appears to use the non-public Notion API -- but it also implements an object model for Notion blocks, which is very helpful for passing around and transforming blocks.

notionpub uses notion-sdk-py as its API client.

⚠️ Major Limitations

  • Images from the filesystem are not uploaded
  • An upload will first delete any existing pages, before re-creating them and populating them with content
    • This prevents viewing page history in Notion

Usage

This project is currently in pre-alpha, but if you manage to download and install it, you can run it like so:

export NOTION_INTEGRATION_SECRET=secret_xyz123
python -m notionpub.main upload ./my/directory/ -c notionpub.yaml

TODO 🔧

  • support configuring "delete-and-recreate" vs "clear page and repopulate"
  • support remaining blocks
    • CodeBlock
    • DividerBlock
    • HeaderBlock
    • ParagraphBlock
    • SubheaderBlock
    • SubsubheaderBlock
    • QuoteBlock
    • TextBlock
    • NumberedListBlock
    • BulletedListBlock
    • ImageBlock
    • CollectionViewBlock
    • TodoBlock
    • EquationBlock
  • implement "bulk block append"
    • at the page level, we should build up the full list of child blocks and "append" them all at once
    • this is tricky because those children may themselves have children, and the parent needs to exist before the children can be uploaded, so a fully-recursive implementation where the "deepest" block is uploaded first, is not possible
    • I suppose this will require some sort of "breadth-first" algorithm, where we build up the first-level child list, upload them all at once, then do the same for each child once we have their id from the api.