Package Exports
- @sindresorhus/slugify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sindresorhus/slugify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
slugify 
Slugify a string
Useful for URLs, filenames, and IDs.
Install
$ npm install @sindresorhus/slugify
Usage
const slugify = require('@sindresorhus/slugify');
slugify('I ♥ Dogs');
//=> 'i-love-dogs'
slugify(' Déjà Vu! ');
//=> 'deja-vu'
slugify('fooBar 123 $#%');
//=> 'foo-bar-123'
slugify('BAR and baz', {separator: '_'});
//=> 'bar_and_baz'
slugify('I ♥ 🦄 & 🐶', {
customReplacements: [
['🐶', 'dog']
]
});
//=> 'i-love-unicorn-and-dog'
API
slugify(input, [options])
input
Type: string
options
Type: Object
separator
Type: string
Default: -
customReplacements
Type: Array
Default: [ ['&', 'and'], ['🦄', 'unicorn'], ['♥', 'love'] ]
Specifying this only replaces the default if you set an item with the same key, like &
.
Related
- slugify-cli - CLI for this module
- filenamify - Convert a string to a valid safe filename
License
MIT © Sindre Sorhus