Skip to content

Commit d0385ea

Browse files
committed
Merge branch 'feat/slug-sep' into chore/all-my-stuffs
2 parents aa61e3a + b9725ea commit d0385ea

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/tools/slugify-string/slugify-string.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,35 @@
22
import slugify from '@sindresorhus/slugify';
33
import { withDefaultOnError } from '@/utils/defaults';
44
import { useCopy } from '@/composable/copy';
5+
import { useQueryParamOrStorage } from '@/composable/queryParams';
56
67
const input = ref('');
7-
const slug = computed(() => withDefaultOnError(() => slugify(input.value), ''));
8+
const separator = useQueryParamOrStorage({ name: 'sep', storageName: 'slugify:sep', defaultValue: '-' });
9+
const slug = computed(() => withDefaultOnError(() => slugify(input.value, {
10+
separator: separator.value,
11+
}), ''));
812
const { copy } = useCopy({ source: slug, text: 'Slug copied to clipboard' });
913
</script>
1014

1115
<template>
1216
<div>
13-
<c-input-text v-model:value="input" multiline placeholder="Put your string here (ex: My file path)" label="Your string to slugify" autofocus raw-text mb-5 />
17+
<c-input-text
18+
v-model:value="input" multiline
19+
placeholder="Put your string here (ex: My file path)"
20+
label="Your string to slugify" autofocus raw-text mb-2
21+
/>
1422

15-
<c-input-text :value="slug" multiline readonly placeholder="You slug will be generated here (ex: my-file-path)" label="Your slug" mb-5 />
23+
<c-input-text
24+
v-model:value="separator"
25+
placeholder="Put separator char here"
26+
label="Separator character" raw-text mb-5
27+
/>
28+
29+
<c-input-text
30+
:value="slug" multiline readonly
31+
placeholder="You slug will be generated here (ex: my-file-path)"
32+
label="Your slug" mb-5
33+
/>
1634

1735
<div flex justify-center>
1836
<c-button :disabled="slug.length === 0" @click="copy()">

0 commit comments

Comments
 (0)