Use Netlify Functions and the Twitter API v2 as a CMS for Your Gatsby Blog
paulie.devI would just make a request to Twitter for the profile on build for the two sites. Do you expect to update your profile more frequently than your two sites? ISTM, you can just trigger manual builds when you do update your profile, instead of using a function, which is going to constantly be looking up and returning the same information.
Hey, and yes that would also work, as you say, for profile information that doesn't change that often it would perhaps be the better option. However, since this is a tutorial blog post it's aim was to inform readers of "one" way you can use Twitter as a CMS. There are of course many other ways to achieve this.
Comments so far are negative, but not every solution needs to scale. I recently made a Netlify site where the CMS is just writing JSON out to GitHub. Yes, if GitHub goes down, it will break, but who cares? My site expects to only get a couple of weeks of editing every few years, so I don’t need something with more availability than that.
Not sure if using 3rd party services for a CMS is a good idea. What happens if this API or Netlify goes down?
Doesn't seem reliable.
If the Twitter API is down, then you'll have blank spots on your page where there are supposed to be tweets.
If Netlify goes down, you won't be able to publish, but your statically rendered site should still load just fine unless you are using it to make dynamic queries on the fly (which is, I think not generally done for Gatsby, but very possible to do)
A fair point. Also true for any front end that relies on an API to populate its data. Hacker News for instance will use a similar approach. If they concern is that sometimes API's may go down and data won't be displayed you can of course chose not to use API's in your front end. If you're not that bothered like me, that this is just. "one" way you "could" use Twitter as a CMS for you blog.
You are always relying on a 3rd party somewhere down the stack that's not a reason to dismiss a solution alone.
Given Twitter's track record on APIs, there is every reason to dismiss this solution.
To be fair, this is something they've acknowledged and committed to working on for future API iterations.
I can host a blog such that it only requires 2nd parties:
- My ISP
- My power company
What would you use for DNS?
edit: Also they're third party. 1st is you 2nd party is the customer (The blog audience).
In this post I'm going to explain how you can use Netlify Functions to access your Twitter profile data using the Twitter v2 API and display it on your Gatsby blog.
Unrelated, but I love your theme and how snappy your blog is :)
Lovely stuff. Thanks!
How about “no”.
How about "why not?"
Well it depends. Do you expect your writing to be accessible in 50 years?
This is harnessing about 2 million lines of code in three different systems, to achieve what amounts to copy & paste text from their Twitter bio.
Seems like a great solution to streamline your personal online presence. If you don’t have a Twitter you could probably do the same thing with GitHub or Instagram
For my blog , i am using Github as CMS using the github API. It simply works.
Yeah lovely stuff. I'm working on a similar "thing" using Octokit. I like experimenting with things that aren't supposed to be used as CMS's as CMS's