File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 2
2
import slugify from ' @sindresorhus/slugify' ;
3
3
import { withDefaultOnError } from ' @/utils/defaults' ;
4
4
import { useCopy } from ' @/composable/copy' ;
5
+ import { useQueryParamOrStorage } from ' @/composable/queryParams' ;
5
6
6
7
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
+ }), ' ' ));
8
12
const { copy } = useCopy ({ source: slug , text: ' Slug copied to clipboard' });
9
13
</script >
10
14
11
15
<template >
12
16
<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
+ />
14
22
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
+ />
16
34
17
35
<div flex justify-center >
18
36
<c-button :disabled =" slug.length === 0" @click =" copy()" >
You can’t perform that action at this time.
0 commit comments