Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dunosaurs/slug
Deno library for converting arbitrary strings into valid slugs
https://github.com/dunosaurs/slug
deno slug slugify typescript unicode
Last synced: 3 months ago
JSON representation
Deno library for converting arbitrary strings into valid slugs
- Host: GitHub
- URL: https://github.com/dunosaurs/slug
- Owner: dunosaurs
- License: mit
- Created: 2022-05-03T03:49:41.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-27T22:29:39.000Z (about 2 years ago)
- Last Synced: 2024-11-18T15:15:26.232Z (3 months ago)
- Topics: deno, slug, slugify, typescript, unicode
- Language: TypeScript
- Homepage: https://deno.land/x/slug
- Size: 19.5 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slug
> Deno library for converting arbitrary strings into valid slugs
```typescript
import { slug } from "https://deno.land/x/slug/mod.ts";console.log(slug("some string")); // some-string
console.log(slug("some string", "_")); // some_string
console.log(slug("I ♥ UNICODE")); // i-love-unicode
console.log(slug("I ♥ UNICODE", { lower: false })); // I-love-UNICODE
```## Options
```typescript
slug("some ƒÚÑķÝ and ☢ string", {
replacement: "-", // replace spaces with replacement character (defaults to `-`)
remove: /[^\w\s$*_+~.()'"!\-:@]+/g, // remove characters that match regex (defaults to `/[^\w\s$*_+~.()'"!\-:@]+/g`)
lower: true, // convert to lower case (defaults to `true`)
strict: false, // strip special characters except replacement (defaults to `false`)
locale: "vi", // language code of the locale to use (defaults to `vi`)
trim: true, // trim leading and trailing replacement chars (defaults to `true`)
extends: { "☢": "nuclear" }, // extend default unicode character set (defaults to `{}`)
}); // some-funky-and-nuclear-string
```## Propers
Heavily inspired by: [Slug](https://www.npmjs.com/package/slug) and
[Slugify](https://www.npmjs.com/package/slugify)