Generate a slug just like GitHub does for markdown headings. It also ensures slugs are unique in the same way GitHub does it. The overall goal of this package is to emulate the way GitHub handles generating markdown heading anchors as close as possible.
npm install github-slugger
var GithubSlugger =var slugger =slugger// returns 'foo'slugger// returns 'foo-1'slugger// returns 'bar'slugger// returns 'foo-2'sluggerslugger// returns 'foo'
test/index.js for more examples.
If you need, you can also use the underlying implementation which does not keep track of the previously slugged strings (not recommended):
var slugger = slug;// returns 'foo-bar-baz'// returns the same slug 'foo-bar-baz' because it does not keep track
Contributions welcome! Please read the contributing guidelines first.