react-notion-x icon indicating copy to clipboard operation
react-notion-x copied to clipboard

Alternative to notion-client format?

Open dev-on2air opened this issue 4 years ago • 7 comments
trafficstars

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?

dev-on2air avatar Nov 11 '21 05:11 dev-on2air

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

transitive-bullshit avatar Nov 11 '21 07:11 transitive-bullshit

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?

dev-on2air avatar Nov 11 '21 16:11 dev-on2air

@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.

pbteja1998 avatar Dec 08 '21 05:12 pbteja1998

@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

dev-on2air avatar Dec 08 '21 18:12 dev-on2air

@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 avatar Dec 09 '21 01:12 pbteja1998

@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.

pbteja1998 avatar Dec 09 '21 01:12 pbteja1998

@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.

dev-on2air avatar Dec 09 '21 22:12 dev-on2air