added unicode support
This commit is contained in:
parent
b20ba676ac
commit
7ebe2e558d
2 changed files with 38 additions and 5 deletions
25
README.md
25
README.md
|
@ -1,7 +1,5 @@
|
|||
# hexo-filter-github-emojis
|
||||
|
||||
[](https://travis-ci.org/crimx/hexo-filter-github-emojis)
|
||||
[](https://coveralls.io/r/crimx/hexo-filter-github-emojis?branch=master)
|
||||
[](https://npmjs.org/package/hexo-filter-github-emojis)
|
||||
[](https://npmjs.org/package/hexo-filter-github-emojis)
|
||||
[](https://npmjs.org/package/hexo-filter-github-emojis)
|
||||
|
@ -26,6 +24,7 @@ githubEmojis:
|
|||
enable: true
|
||||
className: github-emoji
|
||||
localEmojis:
|
||||
unicode: false
|
||||
```
|
||||
|
||||
The filter will try to download the latest version of [Github Emojis][ghemojis] list. If the network is unavailable or too slow it will use the backup version.
|
||||
|
@ -47,4 +46,26 @@ The filter will try to download the latest version of [Github Emojis][ghemojis]
|
|||
arrow_right: https://path/tp/arrow_right.png
|
||||
```
|
||||
|
||||
- **unicode** - If you set this option to true, the filter will generate something like this:
|
||||
|
||||
```html
|
||||
<span class="github-emoji" title=":sparkles:" data-src="https://assets-cdn.github.com/images/icons/emoji/unicode/2728.png">✨</span>
|
||||
```
|
||||
Then you can fallback to image with JavaScript. For example, with jQuery:
|
||||
|
||||
```javascript
|
||||
$('span.github-emoji').each(function (i, emoji) {
|
||||
var $emoji = $(emoji)
|
||||
var codepoint = $emoji.html()
|
||||
$('<img height="20" width="20">')
|
||||
.prop('src', $emoji.data('src'))
|
||||
.prop('alt', $emoji.attr('title'))
|
||||
.on('error', function () {
|
||||
// image loading failed
|
||||
$emoji.html(codepoint)
|
||||
})
|
||||
.appendTo($emoji.empty())
|
||||
})
|
||||
```
|
||||
|
||||
[ghemojis]: https://api.github.com/emojis
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue