Neat Slug for Node.js
Neat Slug is a simple Node.js module that concatenates keywords of a string with the '-' symbol. There are zero dependencies to this package, so it's very lightweight and quick to install and test.
Install Neat Slug using npm
npm install neat-slug
To use Neat Slug, simply require it, and pass it your title text:
var neatSlug = ; // Make "Oh What a Wonderful World" a slug:var slug = ;console; // -> 'wonderful-world' // Turn the title "How to Lose a Guy in Ten Days" into a slug:slug = ;// Slug = 'lose-guy-ten-days'
Neat Slug can also handle more complex strings, as in the example below:
var titleString = "123 1 2 3 @This., -34/ 1234 #! 90182.2312 $ % ^" + " & 1* green ;123: {} 123 a = 123123-_ smoothies with `~)() kale"; var slug = ;console; // -> green-smoothies-kale
Credits
- Stopwords are from http://jmlr.org/papers/volume5/lewis04a/a11-smart-stop-list/english.stop