This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@z1574242600/gatsby-transformer-inline-svg-v2

1.1.1 • Public • Published

gatsby-transformer-inline-svg-v2

Inline and optimize SVG's from your GraphQL data source

Differences From gatsby-transformer-inline-svg

gatsby-transformer-inline-svg currently only works with Contentful assets and doesn't work with File nodes, so this plugin aims to be CMS agnostic, it can still work with CMS images if they are added via the gatsby-source-filesystem via the createRemoteFileNode API

Installation

npm i gatsby-transformer-inline-svg

Usage

gatsby-config.js:

module.exports = {
  plugins: [
    'gatsby-transformer-inline-svg-v2'
  ]
}

GraphQL Query:

file {
    childInlineSvg {
        content
    }
    url
}

Rendering:

import React from 'react'

export default function Image({ file }) {
    // inlined SVG
    if (file?.childInlineSvg?.content) {
        return <div dangerouslySetInnerHTML={{ __html: file?.childInlineSvg?.content }} />
    }

    // other images
    return <img src={file.url} alt={alt} />
}

Package Sidebar

Install

npm i @z1574242600/gatsby-transformer-inline-svg-v2

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

7.02 kB

Total Files

5

Last publish

Collaborators

  • z1574242600