NotionX / react-notion-x

Fast and accurate React renderer for Notion. TS batteries included. ⚡️
https://react-notion-x-demo.transitivebullsh.it
MIT License
4.77k stars 554 forks source link

Alternative to notion-client format? #160

Open on2air opened 2 years ago

on2air commented 2 years ago

Great library. Loving it so far.

My use case: Wanting to render page server side inside of Cloudflare Workers. Rendering is working (thanks to use of flareact.com)

Only piece not working is the notion-client. I can't use that library within Cloudflare Workers due to dependance of 'got' library which doesnt run in Cloudflare.

I noticed you had the fetch() implemented originally but is commented out. I'm wondering if I fork notion-client and use fetch (which does work in CF) instead of got if that would work for me?

Or, I can use the Notion API Worker from SplitBee, but it doesn't look like their format is supported by react-notion-x. Is that correct? Is there a way to convert their recordMap format to what is needed for rendering with x?

transitive-bullshit commented 2 years ago

Yeah, I'd be happy to consider switching from got to a fetch-based HTTP lib.

Possibly https://github.com/sindresorhus/ky by the same author, as they both have some really nice support for smart automatic retries. Seems like it's supported within CF workers with a slight caveat https://github.com/sindresorhus/ky/issues/366

on2air commented 2 years ago

That would be much appreciated. I could do a PR if you don't intend to get to it any time soon.

What about the SplitBee API Worker? Any way to convert their output format to work with your renderer?

pbteja1998 commented 2 years ago

@transitive-bullshit @on2air

Anyone of you working on this? Is there anything I can do to help? Even I'm trying to use this on Cloudflare Workers and would appreciate if got is replaced with something like fetch.

on2air commented 2 years ago

@pbteja1998 I don't have a PR, but I was able to get it working by simply uncommenting the code that was commented out in lines 583-590 in this file: https://github.com/NotionX/react-notion-x/blob/master/packages/notion-client/src/notion-api.ts

then commenting out the reference above it that uses got

pbteja1998 commented 2 years ago

@on2air OK, thanks. But how are you maintaining that change? Did you publish your own package or are you using something like patch-package?

pbteja1998 commented 2 years ago

@on2air

Also, how is react-notion-x working for you? When I tried to deploy to CW, I'm getting error saying Prism is not defined and prismjs is only being used inside Code component.

on2air commented 2 years ago

@pbteja1998 - I'm working on a Proof of Concept. If we decide to move forward I'll work on a PR to submit. For now its just a single file I'm using standalone with that change.

I didn't get the Prism error. Everything else worked fine in CW once I made the change to fetch.