Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posts only update on build/restart #9

Closed
jgoggles opened this issue Nov 5, 2018 · 3 comments
Closed

Posts only update on build/restart #9

jgoggles opened this issue Nov 5, 2018 · 3 comments

Comments

@jgoggles
Copy link

jgoggles commented Nov 5, 2018

Is there a way to query/scrape IG when the page loads in order to always see the latest posts?Right now the only way to get new posts is restarting gatsby develop or running gatsby build. Will using the IG Graph API accomplish this? It seems like a lot of trouble to go through to get a token just to display the last 6 Instagram posts on my site so I've held off and am using the scraper for now. Thanks!

Edit: is there a way to use the React component lifecycle (ie componentDidMount) for this?

@oorestisime
Copy link
Owner

Hello,

right now no there is no way to get the posts on each request. The only plugin i know that implements this kind of logic is the gatsby-source-filesystem and it is actually using a file watcher to accomplish it when using gatsby develop.

But even if there was a way to have a watcher on gatsby develop, there is no way (that i know) to have this on a live production site since the plugins are not in your source files. I ll ask around but it seems to me that in gatsby logic there is no way to use component lifecycle for actually running plugins.

@jgoggles
Copy link
Author

jgoggles commented Nov 6, 2018

Thanks for the response. I got it to work how I want by taking your getPublicInstagramPosts function and moving that into my component, then calling it in the component's componentDidMount (passing in the IG username). So I sort of had to "extract" your plugin and use the raw source outside of the Gatsby plugin ecosystem.

@oorestisime
Copy link
Owner

yeah obviously this would work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants