styxlab / gatsby-theme-try-ghost

A Gatsby theme to build flaring fast blogs from headless Ghost CMS
MIT License
136 stars 56 forks source link

Allow filtering of Ghost artifacts retrieval #272

Closed chancharles closed 3 years ago

chancharles commented 3 years ago

gatsby-source-try-ghost always attempts to retrieve all Ghost artifacts (posts, pages, authors, and tags). I have a use case where I want to retrieve only a subset of these artifacts. There is currently no such customization.

So, I am proposing that we add a filters option to gatsby-source-try-ghost (which ultimately will be exposed through the theme's siteConfig) to let a user define a set of filters for each artifact. Here's what I have in mind:

{
  resolve: `gatsby-source-try-ghost`,
  options: {
...
    filters: {
      posts: (post) => ...,
      pages: (page) => ...,
      authors: (author) => ...,
      tags: (tag) => ...,
    }
  },
},

All filters are optional and will not filter anything by default.

styxlab commented 3 years ago

Hi @chancharles! I support a filter approach for posts and pages. As there are inherent relations from posts to authors and tags, I would not want to allow filtering those, because you could run into errors with this configuration. So, if you want to make a PR for posts and pages, you can go ahead.

chancharles commented 3 years ago

PR created https://github.com/styxlab/gatsby-theme-try-ghost/pull/273