menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

gatsby-drupal-wg

Gatsby Working Group: Drupal - Drupal module: https://www.drupal.org/project/gatsby - Gatsby source plugin: https://www.gatsbyjs.org/packages/gatsby-source-drupal/

Channels
Team

A Gatsby-based Drupal theming system

April 29, 2019 at 3:26pm

A Gatsby-based Drupal theming system

April 29, 2019 at 3:26pm
I've had this idea for a few weeks about offering a theme variation for Drupal developed with Gatsby. I've seen the discussion below on specific features, like previews. And, there are countless blog posts on fully decoupled sites that pull from Drupal. But, what about offering an alternative within Drupal itself that can be served by Drupal? While this is a fairly large architectural challenge, I think there is a natural fit that actually makes Drupal and Gatsby more relevant.
What do people think?
I'm going to overly trivialize the current state. Right now, Drupal leverages Twig and references assets like CSS and JS. The rendering process maps Drupal-specific data to Twig through naming conventions (theme suggestions) and is capable of generating HTML (this sometimes makes HTML/JS/CSS assets in the files directory too), which then interacts with Drupal's caching system.
Leveraging Gatsby/React components capable of mapping to Drupal's theme suggestions can create this mapping. Invoking Gatsby's build system can happen during a cache clear, basically rebuild the static assets of Gatsby and informing Drupal to update it's caching directives. I think some hooks can be built with some of the popular component-based CSS/JS Gatsby plugins. But, there is some awkwardness in the roles/responsibilities that likely need ironed out.
In Drupal, this could be a base theme. If done thoughtfully, this native support/approach would cover every part of the Drupal system. And, if it's optional, you can turn it on/off as needed. I think you would basically inherit things like Previews in Drupal, but this has deeper benefits around content updates, Views, and much more.
I'd love to hear peoples thoughts. I recognize this is a bigger idea, but wondering if others have explored it.

April 29, 2019 at 4:36pm
this would def be interesting if it works
The Admin UI in Drupal already has some architectural overlap -- it's done in React. I don't know if it's explored some of the problems around the theme suggestions and build hooks needed for caching.