Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tpoisseau/slug

tpoisseau20MIT1.0.1TypeScript support: included

Use the Unicode Luke 🙌

slug, no-charmap

readme

js-slug

This package as no dependency and let you transform any string with special chars into a nice string with only Alpha, Digits and dash caracters. Typical use : Transform a title into a url segment.

Usage

If you use npm, you'll need node >12 because it's a ESM.

  • npm install @tpoisseau/slug
import slug from '@tpoisseau/slug';

If you wan't use it directly in browser

import slug from 'https://github.com/tpoisseau/js-slug/blob/1.0.0/index.mjs';

And then

slug('1 < 2') // 1-2
slug('Hey! How are you') // hey-how-are-you
slug('tôi tên là d͌ức tạ') // toi-ten-la-duc-ta
slug('learn adonis in 30 minutes') // learn-adonis-in-30-minutes