Description
This is a somewhat large refactor of the demo.
- Move all notion fetches behind proxy lambdas (need for CORS,
image.js
already does this).
- Make sure that fetching our proxy endpoints has the correct url on dev / prod (now).
- Move the logic for
getInitialProps
out of the data folder (I'm not sure this is necessary but it was producing the "Rules of Hooks" error on client side transitions as described in the issue).
I've tagged as WIP with a few open questions:
- I must be missing something about exactly why
getInitialProps
throws that hooks error.
- Is there a cleaner way to do this? (less proxy lambdas, should we just have one express server etc)
- What should live in the lambdas vs getInitialProps. Eg. we could make a lambda out of
getNotionData
basically...
- should we be doing any of this before Notion has an official API 😬
Motivation
Mostly https://github.com/zeit/spr-landing/issues/8.
Want the ability to have multiple pages that link together. Current implementation fails on client side transitions due to Notion blocking the browser requests.
I was pretty 😱seeing this demoed in 🇯🇵
Testing
I added a super simple pages/about.js
(not in PR) that links back to the original page with next/link
. Works both locally and on prod.
I forked the Zeit notion page behind the demo and ensured that the SPR feature still works with the refactor (change title and first image).
https://spr-landing.wbunting.now.sh/