Socket
Book a DemoInstallSign in
Socket

gatsby-plugin-template

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-template

Gatsby template plugin for code

0.4.0
latest
Source
npmnpm
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-plugin-template

Load code with template, indent is preserved, only support Gatsby v2

Install

npm install --save gatsby-plugin-template

How to use

In your gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-template',
      options: {
        test: /\/src\/examples\/(?!index).*\.jsx?$/,
        template: `${__dirname}/example-template.js`,
        placeholder: '/*** placeholder ***/',
      },
    },
  ],
}

Options

  • test (regexp) - required, regexp identifies which files should be transformed.
  • template (string) - required, absolute path of the template file.
  • placeholder (string) - placeholder to be replaced, defaults to /*** placeholder ***/.
  • exportResult (string | boolean) - export the transformed content as provided name, defautls to false.
  • exportRaw (string | boolean) - export the raw content as provided name, defautls to false.

Example

  • template
import React from 'react'
import styled, { css } from 'styled-components'

/*** placeholder ***/
  • code
const Button = styled.button`
  border-radius: 3px;
  padding: 0.25em 1em;
  margin: 0 1em;
  background: transparent;
  color: palevioletred;
  border: 2px solid palevioletred;
`;

export default Button
`
  • transformed
import React from 'react'
import styled, { css } from 'styled-components'

const Button = styled.button`
  border-radius: 3px;
  padding: 0.25em 1em;
  margin: 0 1em;
  background: transparent;
  color: palevioletred;
  border: 2px solid palevioletred;
`

export default Button

Keywords

gatsby

FAQs

Package last updated on 09 Sep 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.