Data Layer
On December 9th, 2021, Paul Scanlon from the GatsbyJS team published a blog post detailing how to fetch data from an API and push it to the data layer with Gatsby.
After reading this, I wanted to experiment for myself. There are various reasons to utilize data from APIs in any site or application. My first small experiment was to use the GeoDB Cities API to grab a list of cities and render some basic data to the page.
After this, I wondered if I could use the WordPress API to create a DIY version of gatsby-source-wordpress, querying and processing data myself. While there are numerous high quality tools available to process WordPress data for Gatsby, it is good to know how to do this for myself. For this I am querying the WordPress API for posts from an online magazine called Relevant, creating pages from the returned posts, and rendering the content where necessary.
GeoCities API Data
This is a very basic implementation querying the GeoDB Cities API's free endpoing and displaying the data. View here
DIY Headless WordPress
Gatsby has a great WordPress source plugin, and WPGraphQl is great - but what if I didn't have those tools? I wanted to find out how I could put together my own headless WP source. View here.