Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend themes with subplugins #16593

Closed
lannonbr opened this issue Aug 13, 2019 · 4 comments
Closed

Extend themes with subplugins #16593

lannonbr opened this issue Aug 13, 2019 · 4 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@lannonbr
Copy link
Contributor

lannonbr commented Aug 13, 2019

@lannonbr Any idea what I'm doing wrong here? I'm hoping to extend @narative/gatsby-theme-novela's use of gatsby-transformer-remark: https://github.com/AryanJ-NYC/webdev-coach-blog/blob/move-to-narrative/gatsby-config.js#L32.

Originally posted by @AryanJ-NYC in #15549 (comment)

With plugins that have sub-plugins, how do we particularly extend the a plugin like this so we can add more sub-plugins inside a theme. In this instance @AryanJ-NYC wants to add in an additional remark plugin.

@lannonbr lannonbr added topic: themes type: question or discussion Issue discussing or asking a question about Gatsby labels Aug 13, 2019
@lannonbr
Copy link
Contributor Author

cc: @ChristopherBiscardi

@ChristopherBiscardi
Copy link
Contributor

in the future we'll have an onPluginOptions lifecycle so that all gatsby-transformer-remark sub-plugins could be combined into a single instance. For now themes have to expose the optionality to modify sub-plugins or allow users to turn off the gatsby-transformer-remark plugin and instantiate their own.

@ChristopherBiscardi
Copy link
Contributor

Closing in favor of the feature request ticket at #16697

@daaain
Copy link

daaain commented Jan 30, 2020

@AryanJ-NYC For now, you can do a pretty gross but effective workaround by extending the existing config after requiring it like so:

const narativeMdxConfig = require("@narative/gatsby-theme-novela/gatsby-config.js")(
  {}
).plugins.find(i => i.resolve == "gatsby-plugin-mdx")

module.exports = {
  plugins: [
    {
      resolve: "@narative/gatsby-theme-novela",
      options: {
        contentPosts: "content/posts",
        contentAuthors: "content/authors",
        basePath: "/",
        authorsPage: true,
        sources: {
          local: true
          // contentful: true,
        }
      }
    },
    {
      resolve: `gatsby-plugin-mdx`,
      options: {
        ...narativeMdxConfig.options,
        gatsbyRemarkPlugins: [
          ...narativeMdxConfig.options.gatsbyRemarkPlugins,
          {
            resolve: `gatsby-remark-responsive-iframe`,
            options: {
              wrapperStyle: `margin: 0 0 1.0725rem 0`
            }
          }
        ]
      }
    }
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants