0.0.1 • Published 4 months ago

@fedikit/rehype-custom-emoji v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@fedikit/rehype-custom-emoji

Rehype plugin to support custom emoji (emojo)

Use

import { rehype } from 'rehype'
import { rehypeCustomEmoji, all, category, one, oneMisskey } from '@fedikit/rehype-custom-emoji'

const file = await rehype()
  .use(rehypeCustomEmoji, {
    emojis: [
      // user defined
      {
        shortcode: 'custom_emoji',
        url: 'https://example.com/custom_emoji.png',
      },
      // get all emoji from mastodon instance
      ...(await all('https://mastodon.social')),
      // get category-specific emoji from mastodon instance
      ...(await category('https://mozilla.social', 'Mozilla')),
      // get a specific emoji from mastodon instance
      ...(await one('https://m.webtoo.ls', 'vitest')),
      // get a specific emoji from misskey instance
      ...(await oneMisskey('https://misskey.io', 'ai_acid_misskeyio'))
    ],
  })
  .process(':custom_emoji:')

// <picture>
//   <source media="(prefers-reduced-motion: no-preference)" srcset="https://example.com/custom_emoji.png">
//   <img alt=":custom_emoji:" src="https://example.com/custom_emoji.png" style="aspect-ratio:1/1;height:1em;vertical-align:text-top" title=":custom_emoji:">
// </picture>
console.log(String(file))