Utilities
toSlug

toSlug

Converts a string to a slug.

Installation

npm install @madeinhaus/utils

Import

import { toSlug } from '@madeinhaus/utils';

Parameters

  • str (string): The string to convert to a slug.

Returns

  • (string): The slugified string.

Usage

import { toSlug } from '@madeinhaus/utils';
 
const str = 'Hello, world!';
const slug = toSlug(str); // 'hello-world'

In this example, we import the toSlug function from the @madeinhaus/utils package and use it to convert a string to a slug.