2025-02-23 01:38:42 +01:00
import { stringTools } from '../pages/tools/string' ;
import { imageTools } from '../pages/tools/image' ;
import { DefinedTool , ToolCategory } from './defineTool' ;
2024-06-23 01:26:04 +01:00
import { capitalizeFirstLetter } from '../utils/string' ;
2025-02-23 01:38:42 +01:00
import { numberTools } from '../pages/tools/number' ;
import { videoTools } from '../pages/tools/video' ;
import { listTools } from '../pages/tools/list' ;
import { Entries } from 'type-fest' ;
2025-02-27 13:05:38 +00:00
import { jsonTools } from '../pages/tools/json' ;
2025-03-09 00:41:59 +00:00
import { csvTools } from '../pages/tools/csv' ;
2025-03-24 20:23:28 +00:00
import { timeTools } from '../pages/tools/time' ;
2025-02-27 13:05:38 +00:00
import { IconifyIcon } from '@iconify/react' ;
2025-03-26 05:43:59 +00:00
import { pdfTools } from '../pages/tools/pdf' ;
2024-06-22 22:06:16 +01:00
2024-06-25 03:11:48 +01:00
export const tools : DefinedTool [ ] = [
. . . imageTools ,
. . . stringTools ,
2025-02-27 13:05:38 +00:00
. . . jsonTools ,
2025-02-23 14:11:21 +00:00
. . . listTools ,
2025-03-09 00:41:59 +00:00
. . . csvTools ,
2024-06-27 20:27:03 +01:00
. . . videoTools ,
2025-03-24 20:23:28 +00:00
. . . numberTools ,
2025-03-26 05:43:59 +00:00
. . . timeTools ,
. . . pdfTools
2024-06-25 03:11:48 +01:00
] ;
2025-02-23 01:38:42 +01:00
const categoriesConfig : {
type : ToolCategory ;
value : string ;
title? : string ;
2025-02-27 13:05:38 +00:00
icon : IconifyIcon | string ;
2025-02-23 01:38:42 +01:00
} [ ] = [
2024-06-23 01:26:04 +01:00
{
type : 'string' ,
2025-02-23 01:38:42 +01:00
title : 'Text' ,
2025-02-27 13:05:38 +00:00
icon : 'solar:text-bold-duotone' ,
2024-06-23 01:26:04 +01:00
value :
'Tools for working with text – convert text to images, find and replace text, split text into fragments, join text lines, repeat text, and much more.'
} ,
{
type : 'png' ,
2025-02-27 13:05:38 +00:00
icon : 'ph:file-png-thin' ,
2024-06-23 01:26:04 +01:00
value :
'Tools for working with PNG images – convert PNGs to JPGs, create transparent PNGs, change PNG colors, crop, rotate, resize PNGs, and much more.'
2024-06-25 03:11:48 +01:00
} ,
{
type : 'number' ,
2025-02-27 13:05:38 +00:00
icon : 'lsicon:number-filled' ,
2024-06-25 03:11:48 +01:00
value :
'Tools for working with numbers – generate number sequences, convert numbers to words and words to numbers, sort, round, factor numbers, and much more.'
2024-06-27 12:39:38 +01:00
} ,
{
type : 'gif' ,
2025-02-27 13:05:38 +00:00
icon : 'material-symbols-light:gif-rounded' ,
2024-06-27 12:39:38 +01:00
value :
'Tools for working with GIF animations – create transparent GIFs, extract GIF frames, add text to GIF, crop, rotate, reverse GIFs, and much more.'
2024-06-27 20:27:03 +01:00
} ,
{
type : 'list' ,
2025-02-27 13:05:38 +00:00
icon : 'solar:list-bold-duotone' ,
2024-06-27 20:27:03 +01:00
value :
'Tools for working with lists – sort, reverse, randomize lists, find unique and duplicate list items, change list item separators, and much more.'
2025-02-27 13:05:38 +00:00
} ,
{
type : 'json' ,
icon : 'lets-icons:json-light' ,
value :
'Tools for working with JSON data structures – prettify and minify JSON objects, flatten JSON arrays, stringify JSON values, analyze data, and much more'
2025-03-09 00:41:59 +00:00
} ,
{
type : 'csv' ,
icon : 'material-symbols-light:csv-outline' ,
value :
'Tools for working with CSV files - convert CSV to different formats, manipulate CSV data, validate CSV structure, and process CSV files efficiently.'
2025-03-10 04:13:10 +00:00
} ,
{
type : 'video' ,
icon : 'lets-icons:video-light' ,
value :
'Tools for working with videos – extract frames from videos, create GIFs from videos, convert videos to different formats, and much more.'
2025-03-24 20:23:28 +00:00
} ,
2025-03-26 05:43:59 +00:00
{
type : 'pdf' ,
icon : 'tabler:pdf' ,
value :
'Tools for working with PDF files - extract text from PDFs, convert PDFs to other formats, manipulate PDFs, and much more.'
} ,
2025-03-24 20:23:28 +00:00
{
type : 'time' ,
icon : 'fluent-mdl2:date-time' ,
value :
'Tools for working with time and date – draw clocks and calendars, generate time and date sequences, calculate average time, convert between time zones, and much more.'
2024-06-23 01:26:04 +01:00
}
] ;
2024-06-22 23:31:00 +01:00
export const filterTools = (
tools : DefinedTool [ ] ,
query : string
) : DefinedTool [ ] = > {
if ( ! query ) return tools ;
const lowerCaseQuery = query . toLowerCase ( ) ;
return tools . filter (
( tool ) = >
tool . name . toLowerCase ( ) . includes ( lowerCaseQuery ) ||
tool . description . toLowerCase ( ) . includes ( lowerCaseQuery ) ||
2024-06-25 08:39:29 +01:00
tool . shortDescription . toLowerCase ( ) . includes ( lowerCaseQuery ) ||
2024-06-22 23:31:00 +01:00
tool . keywords . some ( ( keyword ) = >
keyword . toLowerCase ( ) . includes ( lowerCaseQuery )
)
) ;
} ;
2024-06-23 01:26:04 +01:00
export const getToolsByCategory = ( ) : {
title : string ;
description : string ;
2025-02-27 13:05:38 +00:00
icon : IconifyIcon | string ;
2024-06-23 01:26:04 +01:00
type : string ;
example : { title : string ; path : string } ;
2024-06-25 08:39:29 +01:00
tools : DefinedTool [ ] ;
2024-06-23 01:26:04 +01:00
} [ ] = > {
2025-02-23 01:38:42 +01:00
const groupedByType : Partial < Record < ToolCategory , DefinedTool [ ] > > =
Object . groupBy ( tools , ( { type } ) = > type ) ;
return ( Object . entries ( groupedByType ) as Entries < typeof groupedByType > ) . map (
( [ type , tools ] ) = > {
2025-02-23 14:11:21 +00:00
const categoryConfig = categoriesConfig . find (
( config ) = > config . type === type
) ;
2025-02-23 01:38:42 +01:00
return {
2025-02-23 14:11:21 +00:00
title : ` ${ categoryConfig ? . title ? ? capitalizeFirstLetter ( type ) } Tools ` ,
description : categoryConfig?.value ? ? '' ,
2025-02-23 01:38:42 +01:00
type ,
2025-02-23 14:11:21 +00:00
icon : categoryConfig ! . icon ,
2025-02-23 01:38:42 +01:00
tools : tools ? ? [ ] ,
example : tools
? { title : tools [ 0 ] . name , path : tools [ 0 ] . path }
: { title : '' , path : '' }
} ;
}
2024-06-23 01:26:04 +01:00
) ;
} ;