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

https://github.com/markmead/alpinejs-slug

Transform a string into a slug with Alpine JS and Slugify 🐌
https://github.com/markmead/alpinejs-slug

alpine-js alpinejs alpinejs-plugin javascript slug slugify

Last synced: over 1 year ago
JSON representation

Transform a string into a slug with Alpine JS and Slugify 🐌

Awesome Lists containing this project

README

          

# Alpine JS Slug

Transform a string into a slug with Alpine JS and
[Slugify](https://www.npmjs.com/package/slugify) 🐌

## Install

### With a CDN

```html

```

### With a Package Manager

```shell
npm i -D alpinejs-slug

yarn add -D alpinejs-slug
```

```js
import Alpine from 'alpinejs'
import slug from 'alpinejs-slug'

Alpine.plugin(slug)

Alpine.start()
```

## Example

```html








```

### Modifiers

#### `keep-case`

Default: `false`

| Modifier | Value | False | True |
| --------- | ----------- | ----------- | ----------- |
| keep-case | Hello World | hello-world | Hello-World |

#### `replacement`

Default: `-`

If you wanted to use an underscore you'd do so like this `replacement._`

#### `not-strict`

Default: `false`

| Modifier | Value | False | True |
| ---------- | ------------ | ----------- | ------------ |
| not-strict | Hello World! | hello-world | hello-world! |

#### `untrimmed`

Default: `false`

If this modifier is added and the string contains spaces, the spaces will be
replaced with the value of `replacement`.

#### `locale`

Default: `{}`

Set the locale to change how certain characters are transformed. You can see the
list on the
[Slugify repo](https://github.com/simov/slugify/blob/master/config/locales.json).

#### `lazy`

Prevents the `x-slug` input value changing on load. It will only change when the
input `x-slug` is targeting changes.

### Stats

![](https://img.shields.io/bundlephobia/min/alpinejs-slug)
![](https://img.shields.io/npm/v/alpinejs-slug)
![](https://img.shields.io/npm/dt/alpinejs-slug)
![](https://img.shields.io/github/license/markmead/alpinejs-slug)