gatsby-starter-ghost icon indicating copy to clipboard operation
gatsby-starter-ghost copied to clipboard

Global site/config values

Open aileen opened this issue 6 years ago • 1 comments

Problem description

Throughout the codebase we're using values that either come from the starter specific siteConfig.js, or - via Content API - the Ghost settings (like here for example, where we run a StaticQuery in order to use both sources).

Ideally those would be merged together in one site or config, so it's easily accessible by other components/modules.

The biggest pain point here is, that we need the values from the Ghost settings already in the gatsby-config.js! Because of the unavailability of the Ghost settings in this file, we had to create a workaround and adjust the gatsby-offline-manifest plugin (👉 see PR here https://github.com/TryGhost/gatsby-starter-ghost/pull/15)

This is due to Gatsby's specific lifecycle that allows to run GraphQL queries only after the first schema creation. This means at the point when Gatsby is processing the config file, it simply doesn't know about Ghost settings yet.

Proposal

Create a script, that runs before any Gatsby activities and fetches the data from the settings endpoint via Content API (without gatsby-source-ghost usage) and make those merged values available in gatsby-config (and ofc any other occurrences). This can be a .json file for example that get's replaced with every build.

Todos

  • [ ] Finalise idea for this solution. Maybe there are better ways of doing that, then the proposed way?
  • [ ] Implement solution
  • [ ] Replace all StaticQuery occurrences for allGhostSettings and use new solution
  • [ ] Revert https://github.com/TryGhost/gatsby-starter-ghost/pull/15 and use default again

aileen avatar Jan 11 '19 04:01 aileen

Is this enhancement still of interest or did you find a better approach in the meantime?

styxlab avatar Feb 11 '20 23:02 styxlab