Skip to content

Turns strings into user-friendly and search engine-friendly URL slugs.

License

Notifications You must be signed in to change notification settings

danieldietrich/slugify

Repository files navigation

npm versionvulnerabilitiesminzipped sizetypeslicense   buildcoverage   donatepatrons   Follow

slugify

Turns strings into user-friendly and search engine-friendly URL slugs.

Slugify uses a dictionary to translate certain glyphs to the alphabet [a-zA-Z0-9]. The words are joined with hyphen '-' by default.

A highlight of this solution is the readability of slugs. Only words and a single separator type are used.

Installation

npm i @danieldietrich/slugify

Usage

The module supports ES6 import and CommonJS require style.

import slugify from 'slugify';

// I-love-it
slugify('I ♥ it!');

// I_love_it
slugify('I ♥ it!', '_');

// cafebab3-gmail-com
slugify('[email protected]');

Copyright © 2019 by Daniel Dietrich. Released under the MIT license.