Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-transformer-code

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-transformer-code

Gatsby transformer plugin for code

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gatsby-transformer-code

Load raw code of files

Install

npm install --save gatsby-transformer-code

Note: You also need to have gatsby-source-filesystem installed and configured so it points to your files.

How to use

In your gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `examples`,
        path: `./path/to/examples`,
      },
    },
    {
      resolve: `gatsby-transformer-code`,
      options: {
        name: `examples`,
      },
    },
  ],
}

Where the source folder ./path/to/examples contains the example files.

Options

  • name - required, should be the same with the one from gatsby-source-filesystem.
  • extensions - optional, only files with supported extensions will be transformed, default to ['js', 'jsx'].
  • test - optional, regexp identifies which files should be transformed, if provided, extensions will be ignored.

How to query

You can query the nodes using GraphQL, like from the GraphiQL browser: localhost:8000/___graphql.

Regardless of whether you choose to structure your data in arrays of objects or single objects, you'd be able to query your letters like:

{
  allRawCode {
    edges {
      node {
        name
        content
        extension
        instanceName
      }
    }
  }
}

Keywords

FAQs

Package last updated on 26 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc