Gatsby Theme Catalyst was designed from the ground up with headless CMS providers in mind. MDX is an amazing content authoring format, with one giant caveat, it isn’t accessible to non-developers. Business owners and content creators need a Wordpress-like authoring experience with a GUI.
There are a lot of amazing headless CMS products out there right now. I chose SANITY.io due to the ability to commit their “content studio” to git, generous free pricing tier (and pay as you go afterwards), and pre-existing integrations with Gatsby Cloud for previews.
This led to the creation of a core “data theme” for SANITY.io which is
gatsby-theme-catalyst-sanity. Which layers on top of
gatsby-theme-catalyst-core to handle the integration with SANITY.io.
If you want to poke around in a code example and see how this is all done check out gatsby-theme-catalyst-hydrogen. This is an example of stacking multiple layout themes, with a data theme, and then a final presentation theme.
You can try out an integration with SANITY.io’s create API by visiting https://create.sanity.io/?template=ehowey/sanity-template-bery
What is working
Separation of query components and presentation components: This pattern enables easier shadowing of either the query or the presentation component in the final site to make it more straightforward to build distinct design elements without having to modify the data source. This is similar to the pattern used in
Custom data sourcing in the starter: Any custom data structures and
gatsby-node.jsintegrations can be created in the final site using similar patterns to what is done in the theme. For example if you wanted to setup a “restaurants” data type and source it in your frontend this is possible to do.
Theme options as feature flags: Theme options like
sanityCreatePostsact as feature flags in
gatsby-node.jsto control what pages are created by the theme. This allows you conditionally create or not create certain pages from the content studio.
Site Settings: Component shadowing is used to shadow the site metadata hook,
useSiteMetadata.jsto switch the data source of this hook. Instead of looking for the site title in
gatsby-configit pulls this site title from SANITY.io.
Seo: Component shadowing is used again on the
seo.jsto replace default social sharing images and source relevant of data from SANITY.io
Theme-UI Styles: Styles (colors, fonts, spacing, etc) set in Theme-UI apply to content coming from SANITY.io.
What isn’t working
Gatsby-Plugin-Manifest: This plugin still has to be manually configured in
siteUrl: This field still has to be completed in
gatsby-config.jsbecause it is used by other plugins to create
sitemap.xml. Due to how this happens it isn’t possible to pull this value from SANITY.io at this time.