github emojis for hexo! 🎉
Find a file
2016-12-25 18:18:12 +08:00
.gitignore first commit 2016-12-22 19:11:28 +08:00
.npmignore first commit 2016-12-22 19:11:28 +08:00
emojis.json added JSON file writing 2016-12-23 18:46:01 +08:00
index.js fixed stop yelling error for unset local emojis 2016-12-25 18:18:12 +08:00
LICENSE added MIT License 2016-12-24 16:36:24 +08:00
package.json bumped version to 1.1.0 2016-12-23 18:46:35 +08:00
README.md fixed yaml highlight 2016-12-23 18:50:32 +08:00

hexo-filter-github-emojis

Npm Version Npm Downloads Month Npm Downloads Total License

A Hexo plugin that adds emoji support, using Github Emojis API.

Check out the Emoji Cheat Sheet for all the emojis it supports.

Installation

$ npm install hexo-filter-github-emojis --save

Options

You can configure this plugin in _config.yml. Default options:

githubEmojis:
  enable: true
  className: github-emoji
  unicode: false
  localEmojis:

The filter will try to download the latest version of Github Emojis list. If the network is unavailable or too slow it will use the backup version.

  • className - Image class name. For :sparkles: the filter will generate something like this:

    <img class="github-emoji" title=":sparkles:" alt=":sparkles:" src="https://assets-cdn.github.com/images/icons/emoji/unicode/2728.png" height="20" width="20">
    
  • unicode - If you set this option to true, the filter will generate something like this:

    <span class="github-emoji" title=":sparkles:" data-src="https://assets-cdn.github.com/images/icons/emoji/unicode/2728.png">&#x2728;</span>
    

    Then you can fallback to image with JavaScript. For example, with jQuery:

      $('span.github-emoji').each(function (i, emoji) {
        var $emoji = $(emoji)
        var codepoint = $emoji.html()
        $('<img height="20" width="20">')
          .on('error', function () {
            // image loading failed
            $emoji.html(codepoint)
          })
          .prop('alt', $emoji.attr('title'))
          .prop('src', $emoji.data('src'))
          .appendTo($emoji.empty())
      })
    
  • localEmojis - You can specify your own list. An object or JSON string is valid. The filter will first check the localEmojis then fallback to the Github Emojis list.

    For example:

    githubEmojis:
      localEmojis:
        arrow_left: https://path/to/arrow_left.png
        arrow_right: https://path/to/arrow_right.png
    

    If you need to add code points that are not in the Github list, you can do this:

    githubEmojis:
      localEmojis:
        man_juggling:
          src: https://path/to/man_juggling.png
          codepoints: ["1f939", "2642"]
        arrow_right: https://path/to/arrow_right.png