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

0.0.6 • Public • Published

Rehype Twemoji

A rehype plugin to convert emoji to twemoji.

Install

pnpm i -D rehype-twemoji

Usage

import { rehypeTwemoji } from 'rehype-twemoji'
import type { RehypeTwemojiOptions } from 'rehype-twemoji'

...

{
  rehypePlugins: [
    [rehypeTwemoji, {
      format: 'svg',
      source: 'https://cdn.jsdelivr.net/gh/twitter/twemoji@latest',
    } satisfies RehypeTwemojiOptions],
  ]
}

Input:

Hello World 👋

Output:

<p>
  Hello World
  <img
    src="https://cdn.jsdelivr.net/gh/twitter/twemoji@latest/assets/svg/1f44b.svg"
    alt="👋"
    aria-label="waving hand"
    data-twemoji=""
  />
</p>

Options

  • format: svg or png (default: svg)
  • source: source of twemoji (default: https://cdn.jsdelivr.net/gh/twitter/twemoji@latest)

Styling

You can use data-twemoji attribute to style the emoji.

Here is an example of using with Tailwind CSS:

[data-twemoji] {
  @apply size-[1.2em] inline-block align-text-bottom;
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i rehype-twemoji

Weekly Downloads

10

Version

0.0.6

License

MIT

Unpacked Size

5.7 kB

Total Files

8

Last publish

Collaborators

  • nekochan0122