This is a Gatsby transformer plugin designed to extract metadata, commonly known as "frontmatter," directly from JavaScript, TypeScript, JSX, or TSX files within a Gatsby project. It operates by statically analyzing `exports.frontmatter` or `export const frontmatter` declarations using `@babel/parser` and `@babel/traverse`. The current stable version, `5.16.0`, aligns with the Gatsby v5 ecosystem. Its release cadence is tied to the main Gatsby monorepo, receiving updates alongside Gatsby core to ensure compatibility with new Node.js versions (e.g., Node.js 24 support in `5.16.0`) and address security vulnerabilities. Its key differentiator is enabling developers to define content metadata directly within their component or data files using standard JavaScript exports, providing a unified location for code and content configuration, distinct from traditional Markdown-based frontmatter solutions.
npm install gatsby-transformer-javascript-frontmatterVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure `gatsby-transformer-javascript-frontmatter` in `gatsby-config.js` alongside `gatsby-source-filesystem` and provides an example JavaScript file showing how to export frontmatter for the plugin to process.
Upgrade your Node.js environment to a supported version (e.g., Node.js 18 LTS, 20 LTS, or 22 LTS). Refer to Gatsby's official documentation for the latest Node.js compatibility matrix.
Ensure that `gatsby` and `gatsby-source-filesystem` are installed at version `^5.0.0` or higher in your project's `package.json`.
Ensure that your `exports.frontmatter` or `export const frontmatter` objects are statically analyzable, containing only primitive values or simple object/array literals. Avoid complex function calls or runtime calculations within the frontmatter definition itself.
Always use `export const frontmatter = { ... }` or `exports.frontmatter = { ... }` to define your metadata in JavaScript files.Verify that `gatsby-transformer-javascript-frontmatter` is listed in your `plugins` array in `gatsby-config.js` and that `gatsby-source-filesystem` is configured to include the paths to your JavaScript/TypeScript files.
Install `gatsby` and `gatsby-source-filesystem` at version `^5.0.0` or higher: `npm install gatsby gatsby-source-filesystem` or `yarn add gatsby gatsby-source-filesystem`.
Check the source JavaScript/TypeScript file to ensure `export const frontmatter = { ... }` or `exports.frontmatter = { ... }` is used and that the content is statically analyzable. The GraphQL query also exposes an `error` field you can query to get detailed parsing errors.