@gaiama/slugger
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@gaiama/slugger

Early release

⚠️ Things may change and could even break.

It's an opinionated slugger wrapping @sindresorhus/slugify.
It pre-defines settings and adds a counter to handle multiple occurrences of the same slug.
This feature is already being discussed in #37 so it might end up in "upstream" soon-ish. 🤷‍♂️

This package is basically to satisfy our requirements and ensure consistency.
If tests start to fail only this package has to be fixed. 😉

Install

yarn add @gaiama/slugger
# or
npm i @gaiama/slugger

Usage

import { slugify } from '@gaiama/slugger'
slugify('foo') // => foo
slugify('foo') // => foo-2
slugify('foo 1') // => foo-1
slugify('foo-1') // => foo-1-2
slugify('foo-1') // => foo-1-3
slugify('foo') // => foo-3
slugify('foo') // => foo-4
slugify('foo-1') // => foo-1-4
slugify('foo-2') // => foo-2-1
slugify('foo-2') // => foo-2-2
slugify('foo-2-1') // => foo-2-1-1
slugify('foo-2-1') // => foo-2-1-2
slugify('foo-11') // => foo-11-1
slugify('foo-111') // => foo-111-1
slugify('foo-111-1') // => foo-111-1-1

API

slugify(string, options?)

string

Type: string

String to slugify.

options

Type: object

options are passed straight to @sindresorhus/slugify

License

MIT © CanRau

Package Sidebar

Install

npm i @gaiama/slugger

Weekly Downloads

2

Version

0.1.1

License

MIT

Unpacked Size

5.16 kB

Total Files

5

Last publish

Collaborators

  • canrau