ns

neat-slug

Node.js module that returns a neat URL slug for a given string

Showing:

Popularity

Downloads/wk

0

GitHub Stars

0

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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 = require('neat-slug');

// Make "Oh What a Wonderful World" a slug:
var slug = neatSlug("Oh what a wonderful world!");
console.log(slug); // -> 'wonderful-world'

// Turn the title "How to Lose a Guy in Ten Days" into a slug:
slug = neatSlug("How to lose a guy in ten days");
// 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 = neatSlug(titleString);
console.log(slug); // -> green-smoothies-kale

Neat slug also handle Greek and other non-Anglican characters:

console.log(neatSlug("these are umlauts: ÄËÏÖÜäëïöü")); // -> umlauts-AEIOUaeiouss

If all of the words in the string are stopwords, Neat Slug will still return a valid slug:

console.log(neatSlug("the a him")); // -> the-a-him

Credits

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial