railwayapp / blog

77 stars 28 forks source link

Using `getStaticProps` for fetching images hosted on Notion? #8

Closed spencerwooo closed 8 months ago

spencerwooo commented 2 years ago

Hi there, apologies for posting this random question here, but I was curious about how you overcame the issue for rendering images hosted on Notion and also using next/image for optimisation? (As I myself ran into a similar problem when switching to Notion's public API for blog hosting.)

It was not until Next.js 12.1 (released literally yesterday) before we could on-demand ISR with webhooks (On-demand Incremental Static Regeneration). So I was curious about if you had some solutions to this issue without on-demand ISR?

My workaround was that I had to resort to using getServerSideProps without image optimisation for serving fresh images. But I skimmed through your repo and found that you were still using getStaticProps, and hence this question ;)

And thanks for the awesome railway.app, I'm loving it!

jinalex commented 2 years ago

Also interested in this! @spencerwooo have you found a solution by any chance?

sorcererxw commented 2 years ago

I also use Notion as my blog CMS. I find that the images sometimes don't load because they are expried. Therefore, I use a cronjob to regenerate the SSG pages.

The cronjob will load the sitexml and request to revalidate each path, and finally, request each page to make sure the generation is complete.

It works well currently.

jordymeow commented 2 years ago

I am also interested in an elegant solution; I am not sure forcing the SSG pages to regenerate is good, but maybe by finding a way for NextJS to consider an image is the same as previously without the need to optimize it?

FarazPatankar commented 1 year ago

Hey y'all, this is what we're doing for now: https://github.com/railwayapp/blog/pull/18

ImBIOS commented 1 year ago

@FarazPatankar I think this issue was resolved 🥳

christiankaindl commented 1 year ago

Hey y'all, this is what we're doing for now: #18

This solution is very elegant and works great! Thanks :pray: