feat(new-tool): slugify string

This commit is contained in:
Corentin Thomasset 2023-02-10 22:06:32 +01:00
parent 1a3f0a135d
commit 6fe4b5ac60
No known key found for this signature in database
GPG Key ID: DBD997E935996158
5 changed files with 69 additions and 0 deletions

View File

@ -33,6 +33,7 @@
"dependencies": {
"@it-tools/bip39": "^0.0.4",
"@it-tools/oggen": "^1.3.0",
"@sindresorhus/slugify": "^2.2.0",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
"@vueuse/core": "^8.9.4",

View File

@ -4,6 +4,7 @@ specifiers:
'@it-tools/bip39': ^0.0.4
'@it-tools/oggen': ^1.3.0
'@rushstack/eslint-patch': ^1.2.0
'@sindresorhus/slugify': ^2.2.0
'@types/bcryptjs': ^2.4.2
'@types/crypto-js': ^4.1.1
'@types/jsdom': ^16.2.15
@ -73,6 +74,7 @@ specifiers:
dependencies:
'@it-tools/bip39': 0.0.4
'@it-tools/oggen': 1.3.0
'@sindresorhus/slugify': 2.2.0
'@vicons/material': 0.12.0
'@vicons/tabler': 0.12.0
'@vueuse/core': 8.9.4_vue@3.2.45
@ -1622,6 +1624,21 @@ packages:
resolution: {integrity: sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==}
dev: true
/@sindresorhus/slugify/2.2.0:
resolution: {integrity: sha512-9Vybc/qX8Kj6pxJaapjkFbiUJPk7MAkCh/GFCxIBnnsuYCFPIXKvnLidG8xlepht3i24L5XemUmGtrJ3UWrl6w==}
engines: {node: '>=12'}
dependencies:
'@sindresorhus/transliterate': 1.6.0
escape-string-regexp: 5.0.0
dev: false
/@sindresorhus/transliterate/1.6.0:
resolution: {integrity: sha512-doH1gimEu3A46VX6aVxpHTeHrytJAG6HgdxntYnCFiIFHEM/ZGpG8KiZGBChchjQmG0XFIBL552kBTjVcMZXwQ==}
engines: {node: '>=12'}
dependencies:
escape-string-regexp: 5.0.0
dev: false
/@surma/rollup-plugin-off-main-thread/2.2.3:
resolution: {integrity: sha512-lR8q/9W7hZpMWweNiAKU7NQerBnzQQLvi8qnTDU/fxItPhtZVMbPV3lbCwjhIlNBe9Bbr5V+KHshvWmVSG9cxQ==}
dependencies:
@ -3581,6 +3598,11 @@ packages:
engines: {node: '>=10'}
dev: true
/escape-string-regexp/5.0.0:
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
engines: {node: '>=12'}
dev: false
/escodegen/2.0.0:
resolution: {integrity: sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==}
engines: {node: '>=6.0'}

View File

@ -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,
],
},
{

View 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,
});

View 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>