An open API service indexing awesome lists of open source software.

https://github.com/martpie/react-slugify

Slugify a React node
https://github.com/martpie/react-slugify

react reactjs slug slugify

Last synced: 11 months ago
JSON representation

Slugify a React node

Awesome Lists containing this project

README

          

# react-slugify

![Build status](https://github.com/martpie/react-slugify/workflows/tests/badge.svg)

Slugify a React node.

## Usage

### `slugify(node[, options])`

- `node` String, Number, Fragment, Array of nodes
- `options` Object (optional)
- `delimiter` String (default is `'-'`)
- `prefix` String (default is `''`)

## Examples

```tsx
import slugify from 'react-slugify';

slugify('something I want to test');
// -> "something-i-want-to-test"

slugify(Yes it works like that too);
// -> "yes-it-works-like-that-too"

slugify(
<>
and
with
fragments or arrays
>
);
// -> "and-with-fragments-or-arrays"

slugify(

Crème brulée receipe

, { delimiter: '_' });
// -> creme_brulee_receipe

slugify(

Crème brulée receipe

, { prefix: 'user-content' });
// -> user-content-creme-brulee-receipe

slugify(

Crème brulée receipe

, {
delimiter: '_',
prefix: 'user-content',
});
// -> user-content_creme_brulee_receipe
```