@knownasrazi/slugger
v1.0.0
Published
Generate URL slugs from strings, unicode-aware with stopword removal and custom replacements.
Maintainers
Readme
slugger
Generate URL slugs, unicode-aware.
Zero dependencies - ~2 KB gzipped - TypeScript - Node + Bun + browser
Install
bun add @knownasrazi/slugger
npm install @knownasrazi/sluggerUsage
import { slugger } from "@knownasrazi/slugger";
slugger("Hello World"); // "hello-world"
slugger("The quick brown fox"); // "quick-brown-fox" (stopwords stripped)
slugger("Café résumé"); // "cafe-resume"
slugger("a b c", { separator: "_" }); // "a-b-c"
slugger("hello world", { stopwords: false }); // "hello-world"API
slugger(input: string, options?: SluggerOptions): string
| Option | Type | Default | Description |
| -------------- | ----------------------------- | -------------- | ---------------------------------------- |
| lowercase | boolean | true | Lowercase the output |
| separator | string | "-" | Word separator |
| stopwords | Set \| string[] \| false | built-in list | Words to drop (empty = keep all) |
| replacements | Record<string,string> | {} | Pre-normalization character swaps |
Diacritics are stripped via NFKD normalization. Emoji and punctuation are dropped.
Development
git clone https://github.com/knownasrazi/slugger.git
cd slugger
bun install
bun test
bun run build
bun run lintLicense
slugger - slugs that do not embarrass you.
