rehype-custom-emoji
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

rehype-custom-emoji

rehype plugin to create custom emoji

Installation

# yarn
yarn add rehype-custom-emoji

# npm
npm install rehype-custom-emoji

API

rehype().use(rehypeCustomEmoji, [options])

options

options.emojis

Type: Record<string, string>. Default value: {}

The object have key is an emoji code and value is the path of emoji (url).

Example:

{
  hello: "/emojis/hello.png",
  goodbye: "https://example.com/goodbye.png",
}

options.className

Type: string. Default value: emoji

The class name of image after rendered.

options.ignore

Type: string or string[]. Default value: code

Ignore tag(s) that contain emoji pattern.

options.alt

Type: boolean. Default value: true

Add emoji code to alt property in img tag.

Usage

import { rehype } from 'rehype';
import rehypeCustomEmoji from 'rehype-custom-emoji';

const htmlStr = rehype()
  .data('settings', { fragment: true })
  .use(
    rehypeCustomEmoji, {
      emojis: { hello: "/emoji/hello.png" },
      className: "custom_emoji"
    }
  )
  .processSync(`
    # Hello, world!

    Such a beautiful day :hello:
  `)
  .toString()

License

MIT © Monody Le

Package Sidebar

Install

npm i rehype-custom-emoji

Weekly Downloads

11

Version

1.0.1

License

MIT

Unpacked Size

8.09 kB

Total Files

7

Last publish

Collaborators

  • monodyle