Remark plugin to use Twemoji
npm install remark-twemoji[![prettier][prettier-image]][prettier-url]
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
[prettier-url]: https://github.com/prettier/prettier
[npm-image]: https://img.shields.io/npm/v/remark-twemoji.svg
[npm-url]: https://npmjs.org/package/remark-twemoji
[travis-url]: https://travis-ci.org/madiodio/remark-twemoji
[travis-image]: https://img.shields.io/travis/madiodio/remark-twemoji/master.svg
Remark plugin to replace your emoji by using twemoji.
``bash`
npm install --dev remark-twemoji
`js`
remark().use(remarkTwemoji, { options });
1. Basic usage
`js
const remark = require("remark");
const twemoji = require("remark-twemoji");
const doc = "😂";
remark()
.use(emoji)
.process(doc, function(err, file) {
console.log(String(file));
});
// => 
`
2. Usage with mdx (basically what this plugin has been for):
Somewhere in your webpack config file:
`js
const webpack = require("webpack");
const twemoji = require("remark-twemoji");
...{
test: /\.md$/,
exclude: /node_modules/,
use: [
"babel-loader",
{
loader: "@mdx-js/loader",
options: {
mdPlugins: [twemoji, { isReact: true }]
}
}
]
},...
`
For more informations, check this section on the mdx docs.
When using this plugin in a React setup, Twemoji will parse a dom node containing the attribute class instead of className which causes a warning at runtime. So if you're using React in your setup, use this to instruct the plugin to replace class by className in the final node, eg: ...[twemoji, { isReact: true }]...
`js``
{
callback: Function, // default the common replacer
attributes: Function, // default returns {}
base: string, // default MaxCDN
ext: string, // default ".png"
className: string, // default "emoji"
size: string|number, // default "36x36"
folder: string // in case it's specified
// it replaces .size info, if any
}
These are the options you can pass to this plugin as the twemoji options, you can read more about them here.
* gatsby-remark-twemoji
* remark-emoji
MIT