justjake / monorepo

GNU Affero General Public License v3.0
40 stars 2 forks source link

[notion-api] Convert pages and blocks to Markdown #7

Open smor opened 2 years ago

smor commented 2 years ago

Hello Jake,

Thanks for the great work on this API wrapper, it does help a lot in managing Notion source data.

I'm building for my team of tech teachers a course writing pipeline from Notion to LMS-enabled websites through Hugo, in TypeScript. The core library, called notion-to-hugo, fetches Notion pages and blocks with the official Notion API, and converts them to Markdown using notion-to-md, and some custom FeathersJS hooks.

The process is described here : https://ml-ssg.gitlab.io/notion-to-hugo/en/features/#mermaid

I would love to ease my pain with the hard-to-understand Notion API, by using yours instead.

The fetching part is OK, but I can't find a way to use notion-to-md to process the Page and Block data coming from your API. It uses the Notion ones: GetPageResponse, ListBlockChildrenResponseResult etc. I'm trying to get a Notion SDK GetPageResponse from one Page of your API, but TypeScript can't find any overlap. The complexity of the Types used by Notion's SDK and my lack of knowledge of such advanced TypeScript typing kind of deterred me from investigating further. Does your API provide helpers functions to get standard Notion SDK object from your objects ?

I'm ready to switch to other methods to generate my markdown of course. You mention mdast in your blog post. Would you mind explaining how you go from a Page to markdown content using mdast ? I don't see anything related to it in the repo.

Best regards, Stéphane

justjake commented 2 years ago

My Notion -> Markdown converter is in the private repo I use to build my website, and I don't have time to open-source it or update this library right now. The official Notion SDK now exports a bunch of named types as of v2.1, do those work better for you? https://github.com/makenotion/notion-sdk-js/pull/319

smor commented 2 years ago

Hi,

Thanks for the quick answer. I didn't see this very welcome update to the types exposed by Notion's SDK. I'll start a new investigation from there: it should help !