How to create slug url for your title

0
Posted at January 9, 2022 36 Views . 0 Saved .

Install Slugify Library by using npm command

Slugify expects one mandatory string parameter to convert it into slug

eg:

slugify("How to create slug url for your title")

output: How-to-create-slug-url-for-your-title

What if you have some special characters in your code then you will nnot want that special character become part of your slug url

eg:

slugify("How to create slug url for your title ?")

output: How-to-create-slug-url-for-your-title-?

bad

very bad

you can give another optional object to tell slugify what to keep and what to remove

For example, to remove *+~.()'"!:@ from the result slug, you can use slugify('..', {remove: /[*+~.()'"!:@]/g}).

India
Coding is an art and I love art
0 Comments

Loading..!