Slug
Returns a random slug.
Usage
<script>
import {slug} from "@sveu/shared"
</script>
{slug()}
<script>
import {slug} from "@sveu/shared"
</script>
{slug()}
svelte
Example
CvuhIS
<script lang="ts">
import { slug } from "@sveu/shared"
const options = {
lower: true,
upper: true,
digits: true,
size: 6,
prefix: "",
}
$: slugify = slug(options)
</script>
<h1>{slugify}</h1>
<hr />
<label for="lower">Lower Case</label>
<input id="lower" type="checkbox" bind:checked="{options.lower}" />
<hr />
<label for="upper">Upper Case</label>
<input id="upper" type="checkbox" bind:checked="{options.upper}" />
<hr />
<label for="digits">Digits</label>
<input id="digits" type="checkbox" bind:checked="{options.digits}" />
<hr />
<label for="size">Size</label>
<input id="size" type="text" bind:value="{options.size}" />
<hr />
<label for="prefix">Prefix</label>
<input id="prefix" type="text" bind:value="{options.prefix}" />
<hr />
<script lang="ts">
import { slug } from "@sveu/shared"
const options = {
lower: true,
upper: true,
digits: true,
size: 6,
prefix: "",
}
$: slugify = slug(options)
</script>
<h1>{slugify}</h1>
<hr />
<label for="lower">Lower Case</label>
<input id="lower" type="checkbox" bind:checked="{options.lower}" />
<hr />
<label for="upper">Upper Case</label>
<input id="upper" type="checkbox" bind:checked="{options.upper}" />
<hr />
<label for="digits">Digits</label>
<input id="digits" type="checkbox" bind:checked="{options.digits}" />
<hr />
<label for="size">Size</label>
<input id="size" type="text" bind:value="{options.size}" />
<hr />
<label for="prefix">Prefix</label>
<input id="prefix" type="text" bind:value="{options.prefix}" />
<hr />
svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Click fold/expand code
API
Options
Name | Description | Type | Default |
---|---|---|---|
lower | Use lower letters. | boolean | True |
upper | Use uppercase letters. | boolean | True |
digits | Use digits. | boolean | True |
size | Size of the slug. | number | 6 |
prefix | Text to use as a prefix. | string |