reslug
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Reslug

A library for generating unique slugs from strings. It's useful for generating URL slugs from titles, Markdown headings, etc. Zero dependencies, written in TypeScript, and works in Node.js (also Bun!) and the browser.

Installation

npm install reslug

Usage

import Reslug, { slug } from 'reslug';

const slugger = new Reslug();

slugger.slug('Hello, world!'); // hello-world
slugger.slug('Hello, world!'); // hello-world-1
slugger.slug('Hello, world!'); // hello-world-2
slugger.reset();
slugger.slug('Hello, world!'); // hello-world

// You can also use slug() function to generate
// slugs without context.
slug('Hello, world!'); // hello-world
slug('Hello, world!'); // hello-world

Acknowledgements

This library is a rewrite of github-slugger, made by Flet. You should check his project!

Readme

Keywords

Package Sidebar

Install

npm i reslug

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

6.37 kB

Total Files

6

Last publish

Collaborators

  • guilherssousa