mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-25 01:06:15 -04:00
feat(new-tool): slugify string
This commit is contained in:
parent
1a3f0a135d
commit
6fe4b5ac60
5 changed files with 69 additions and 0 deletions
|
@ -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,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
11
src/tools/slugify-string/index.ts
Normal file
11
src/tools/slugify-string/index.ts
Normal file
|
@ -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,
|
||||
});
|
33
src/tools/slugify-string/slugify-string.vue
Normal file
33
src/tools/slugify-string/slugify-string.vue
Normal file
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue