npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@khinshankhan/emoji-helper-remark

v3.1.1

Published

Remark markdown transformer to replace :emoji: in text with jsx

Downloads

10

Readme

emoji-helper-remark

Remark markdown transformer to replace :emoji: in text with jsx

Install

pnpm add @khinshankhan/emoji-helper-remark

Usage

First, you need to define an emoji lookup and then in your remark plugins you can use it likeso

[
  remarkSimpleEmoji,
  {
    validate: (name: string) => emojiLookup.get(name as EmojiKey),
    lookup: (name: string) => {
      const emoji = emojiLookup.get(name as EmojiKey)
      // NOTE: this should be guranteed due to validate
      return emoji!.alt
    },
  },
],

Params

The param (second argument in the array, the whole object) is

{
  jsx?: boolean,
  jsxElement?: string,
  jsxAttribute?: string,
  validate?: (string) => boolean,
  lookup?: (string) => string,
}

The jsx flag determines whether or not to inject an mdx node (true) or to use a text node (false), and it defaults to true.

The jsxElement key is the name of the injected mdx node. In whatever mdx library you use, you will have to provide a component with this name, and it defaults to Emoji.

The jsxAttribute key is the attribute to map the emoji name onto the jsxElement, it defaults to name. So, if the text is Hello :wave, this will essentially be Emoji({ name: ":wave:" }) by default settings (which is equivalent to <Emoji name=":wave:" />).

The validate key helps cull down false positive matches. I'm no regex master so you may end up with some weird string activating the injection like :weird: (it won't match that, but it could match something not in your emoji lookup). When validate returns false, it'll just create a text node instead of trying to use an emoji.

The lookup key lets you use your lookup info in text nodes. The jsx flag should be false for this. Eg you may want to turn Hello :wave: into Hello 👋 using the ascii value rather than an mdx component because you want to use it for SEO or something. Whatever lookup returns for the name is what gets used.

TODO

  • fix types