gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.

Home Page:https://www.gatsbyjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gatsby-transformer-remark doesn't accept "engines" plugin option for graymatter

amamenko opened this issue · comments

Preliminary Checks

Description

From the Gatsby docs for gatsby-transformer-remark:

gray-matter options
gatsby-transformer-remark uses gray-matter to parse Markdown frontmatter, so you can specify any of the options mentioned in its README in the options key of the plugin.

One of the gray-matter options is options.engines. However, when I supply the engines field onto the gatsby-transformer-remark options like so:

{
    resolve: `gatsby-transformer-remark`,
    options: {
      engines: {
        yaml: {
          parse: (src: string, options: object) => {
            return parse(src, options);
          },
          stringify,
        },
      },
      footnotes: true,
      gfm: true
}

Gatsby throws a warning on build: warn Warning: there are unknown plugin options for "gatsby-transformer-remark": engines Please open an issue at https://ghub.io/gatsby-transformer-remark if you believe this option is valid. This should work and I am therefore filing this issue.

I also see the engines option is entirely missing from the Joi data validation schema of gatsby-transformer-remark in its gatsby-node:

return Joi.object({
    footnotes: Joi.boolean().description(`Activates Footnotes mode (default: true)`),
    gfm: Joi.boolean().description(`Activates GitHub Flavored Markdown mode (default: true)`),
    excerpt_separator: Joi.string().description(`If your Markdown file contains HTML, excerpt will not return a value. In that case, you can set an excerpt_separator to an HTML tag. Edit your Markdown files to include that HTML tag after the text you’d like to appear in the excerpt.`),
    plugins: Joi.subPlugins().description(`A list of remark plugins. See also: https://github.com/gatsbyjs/gatsby/tree/master/examples/using-remark for examples`),
    // TODO(v6): Remove and disallow any custom engines (including JS)
    jsFrontmatterEngine: Joi.boolean().default(false).description(`Enable JS for https://github.com/jonschlinkert/gray-matter#optionsengines`)
  })

Reproduction Link

https://codesandbox.io/p/devbox/withered-snow-c4lrxc

Steps to Reproduce

  1. Add "engines" field to gatsby-transformer-remark options in gatsby-config
  2. Run Gatsby build

Expected Result

No warning for custom engines for gatsby-transformer-remark

Actual Result

I received a build warning:

warn Warning: there are unknown plugin options for "gatsby-transformer-remark": engines
Please open an issue at https://ghub.io/gatsby-transformer-remark if you believe this option is valid.

Environment

System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M1
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
  Browsers:
    Chrome: 122.0.6261.69
    Safari: 17.3.1
  npmPackages:
    gatsby: ^5.13.1 => 5.13.1
    gatsby-plugin-postcss: ^6.13.0 => 6.13.0
    gatsby-plugin-sharp: ^5.13.0 => 5.13.0
    gatsby-source-filesystem: ^5.13.0 => 5.13.0
    gatsby-transformer-json: ^5.13.0 => 5.13.0
    gatsby-transformer-remark: ^6.13.0 => 6.13.0
  npmGlobalPackages:
    gatsby-cli: 5.13.2

Config Flags

No response