gatsby-remark-gemoji-to-image

1.1.1 • Public • Published

gatsby-remark-gemoji-to-image

Build Status

Convert Github offcial gemoji to image element.

Installation

npm i gatsby-remark-gemoji-to-image

Usage

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          'gatsby-remark-gemoji-to-image',
        ]
      }
    }
  ]
}

Options

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-gemoji-to-image',
            // default options, can be ignored
            options: {
              base = 'https://github.githubassets.com/images/icons/emoji/',
              ext = '.png',
              class: ['emoji'],
              style = {
                height: '1.2em',
                display: 'inline',
                position: 'relative',
                top: '0.15em',
                margin: 0
              }
            }
          }
        ]
      }
    }
  ]
}

How it works?

:octocat:

Basically, it convert remark node's ast from

{
  type: 'text',
  value: ':octocat:',
  position: [...]
}

to

{
  type: 'image',
  title: ':octocat:',
  url: 'https://github.githubassets.com/images/icons/emoji/octocat.png',
  alt: ':octocat:',
  data: {
    hName: 'img',
    hProperties: {
      className: ['emoji'],
      style: {
        height: '1.2em',
        display: 'inline',
        position: 'relative',
        top: '0.15em',
        margin: 0
      }
    },
  },
  position: [...]
}

Package Sidebar

Install

npm i gatsby-remark-gemoji-to-image

Weekly Downloads

3

Version

1.1.1

License

MIT

Unpacked Size

27.4 kB

Total Files

5

Last publish

Collaborators

  • up9cloud