diff options
author | 2023-02-10 22:06:32 +0100 | |
---|---|---|
committer | 2023-02-10 22:06:32 +0100 | |
commit | 6fe4b5ac608370547ec8be14afca36b28536c824 (patch) | |
tree | 5a46fd5fc6eec5d54251b80f8a281a8ccb412f93 /src | |
parent | 1a3f0a135d572501cc6aec50f39e09205aa616ca (diff) | |
download | it-tools-6fe4b5ac608370547ec8be14afca36b28536c824.tar.gz it-tools-6fe4b5ac608370547ec8be14afca36b28536c824.tar.zst it-tools-6fe4b5ac608370547ec8be14afca36b28536c824.zip |
feat(new-tool): slugify string
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/index.ts | 2 | ||||
-rw-r--r-- | src/tools/slugify-string/index.ts | 11 | ||||
-rw-r--r-- | src/tools/slugify-string/slugify-string.vue | 33 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/tools/index.ts b/src/tools/index.ts index 2aa56f2..c7f0d98 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,6 +1,7 @@ import { tool as base64FileConverter } from './base64-file-converter'; import { tool as base64StringConverter } from './base64-string-converter'; import { tool as basicAuthGenerator } from './basic-auth-generator'; +import { tool as slugifyString } from './slugify-string'; import { tool as keycodeInfo } from './keycode-info'; import { tool as jsonMinify } from './json-minify'; import { tool as bcrypt } from './bcrypt'; @@ -69,6 +70,7 @@ export const toolsByCategory: ToolCategory[] = [ mimeTypes, jwtParser, keycodeInfo, + slugifyString, ], }, { diff --git a/src/tools/slugify-string/index.ts b/src/tools/slugify-string/index.ts new file mode 100644 index 0000000..8dabcdb --- /dev/null +++ b/src/tools/slugify-string/index.ts @@ -0,0 +1,11 @@ +import { AbcRound } from '@vicons/material'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'Slugify string', + path: '/slugify-string', + description: 'Make a string url, filename and id safe.', + keywords: ['slugify', 'string', 'escape', 'emoji', 'special', 'character', 'space', 'trim'], + component: () => import('./slugify-string.vue'), + icon: AbcRound, +}); diff --git a/src/tools/slugify-string/slugify-string.vue b/src/tools/slugify-string/slugify-string.vue new file mode 100644 index 0000000..be5db14 --- /dev/null +++ b/src/tools/slugify-string/slugify-string.vue @@ -0,0 +1,33 @@ +<template> + <div> + <n-form-item label="Your string to slugify"> + <n-input v-model:value="input" type="textarea" placeholder="Put your string here (ex: My file path)"></n-input> + </n-form-item> + + <n-form-item label="Your slug"> + <n-input + :value="slug" + type="textarea" + readonly + placeholder="You slug will be generated here (ex: my-file-path)" + ></n-input> + </n-form-item> + + <n-space justify="center"> + <n-button secondary :disabled="slug.length === 0" @click="copy">Copy slug</n-button> + </n-space> + </div> +</template> + +<script setup lang="ts"> +import { computed, ref } from 'vue'; +import slugify from '@sindresorhus/slugify'; +import { withDefaultOnError } from '@/utils/defaults'; +import { useCopy } from '@/composable/copy'; + +const input = ref(''); +const slug = computed(() => withDefaultOnError(() => slugify(input.value), '')); +const { copy } = useCopy({ source: slug, text: 'Slug copied to clipboard' }); +</script> + +<style lang="less" scoped></style> |