url-slugify
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 = const urlSlugify = ; urlSlugify// 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 = const urlSlugify = ; // Using default optionsurlSlugify// hello-world-b16lmdaeqdl // Using optional separatorsurlSlugify// hello_world_11vlkkpgyg3 urlSlugify// hello~world~jzbaroggg2 // Replaces not allowed charactersurlSlugify// hello-world-9gh134gk45 // Replaces characters with accents such as ã, í, é, ẽ, ì // with SEO-friendly charactersurlSlugify// this-is-a-test-title-q0zkkrpbzz // Removes whitespaces with the separator ''urlSlugify// helloworldyl822qdy89