1.0.6 • Published 5 years ago

url-slugify v1.0.6

Weekly downloads
287
License
MIT
Repository
github
Last release
5 years ago

url-slugify Build Status npm version

URL Slug generator. It combines a page title and a unique id to create an SEO-friendly slug, safe for use in URL paths and queries.

Install

$ npm install --save url-slugify

Usage

const URLSlugify = require('url-slugify')

const urlSlugify = new URLSlugify();

urlSlugify.slugify('Hello world', '-')
// hello-world-6y6106gq

Documentation

urlSlugify(title: string, separator: string)

Returns the title value converted to a unique SEO-friendly slug.

title

Type: string - The title that will be converted.

separator

Type: string (optional) - The character used to separate the slug fragments, set to '-' by default. Can be set to '-', '_', '~' or ''.

Example

const URLSlugify = require('url-slugify')

const urlSlugify = new URLSlugify();

// Using default options
urlSlugify.slugify('Hello world')
// hello-world-b16lmdaeqdl

// Using optional separators
urlSlugify.slugify('Hello world', '_')
// hello_world_11vlkkpgyg3

urlSlugify.slugify('Hello world', '~')
// hello~world~jzbaroggg2

// Replaces not allowed characters
urlSlugify.slugify('Hello[%) [} world£!')
// hello-world-9gh134gk45

// Replaces characters with accents such as ã, í, é, ẽ, ì 
// with SEO-friendly characters
urlSlugify.slugify('thís îs ã tést tìtlẽ')
// this-is-a-test-title-q0zkkrpbzz

// Removes whitespaces with the separator ''
urlSlugify.slugify('Hello World', '\'\'')
// helloworldyl822qdy89

License

The MIT License

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago