No Preview

Rizwan Khan

Posted on 9 January at 14:49

How to create slug url for your title

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}).

0

39

0

No Preview

Rizwan Khan

India

Coding is an art and I love art

Explore more similar Post

0 Comments

Loading..