2024-06-22 22:06:16 +01:00
|
|
|
import ToolLayout from '../components/ToolLayout';
|
2024-06-26 09:02:05 +01:00
|
|
|
import React, { JSXElementConstructor, LazyExoticComponent } from 'react';
|
2025-02-25 06:17:10 +00:00
|
|
|
import { IconifyIcon } from '@iconify/react';
|
2024-06-22 22:06:16 +01:00
|
|
|
|
|
|
|
|
interface ToolOptions {
|
|
|
|
|
path: string;
|
2025-02-27 02:21:08 +00:00
|
|
|
component: LazyExoticComponent<JSXElementConstructor<ToolComponentProps>>;
|
2024-06-22 22:06:16 +01:00
|
|
|
keywords: string[];
|
2025-03-02 02:58:50 +00:00
|
|
|
icon: IconifyIcon | string;
|
2024-06-22 22:06:16 +01:00
|
|
|
name: string;
|
|
|
|
|
description: string;
|
2024-06-25 08:39:29 +01:00
|
|
|
shortDescription: string;
|
2025-03-09 01:22:23 +00:00
|
|
|
longDescription?: string;
|
2024-06-22 22:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-27 13:05:38 +00:00
|
|
|
export type ToolCategory =
|
|
|
|
|
| 'string'
|
|
|
|
|
| 'png'
|
|
|
|
|
| 'number'
|
|
|
|
|
| 'gif'
|
2025-03-10 04:13:10 +00:00
|
|
|
| 'video'
|
2025-02-27 13:05:38 +00:00
|
|
|
| 'list'
|
2025-03-09 00:41:59 +00:00
|
|
|
| 'json'
|
|
|
|
|
| 'csv';
|
2025-02-23 01:38:42 +01:00
|
|
|
|
2024-06-22 23:31:00 +01:00
|
|
|
export interface DefinedTool {
|
2025-02-23 01:38:42 +01:00
|
|
|
type: ToolCategory;
|
2024-06-22 22:06:16 +01:00
|
|
|
path: string;
|
|
|
|
|
name: string;
|
|
|
|
|
description: string;
|
2024-06-25 08:39:29 +01:00
|
|
|
shortDescription: string;
|
2025-03-02 02:58:50 +00:00
|
|
|
icon: IconifyIcon | string;
|
2024-06-22 22:06:16 +01:00
|
|
|
keywords: string[];
|
|
|
|
|
component: () => JSX.Element;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-27 02:21:08 +00:00
|
|
|
export interface ToolComponentProps {
|
2025-03-09 01:22:23 +00:00
|
|
|
title: string;
|
|
|
|
|
longDescription?: string;
|
2025-02-27 02:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-22 22:06:16 +01:00
|
|
|
export const defineTool = (
|
2025-02-23 01:38:42 +01:00
|
|
|
basePath: ToolCategory,
|
2024-06-22 22:06:16 +01:00
|
|
|
options: ToolOptions
|
|
|
|
|
): DefinedTool => {
|
2024-06-25 08:39:29 +01:00
|
|
|
const {
|
2025-02-25 06:17:10 +00:00
|
|
|
icon,
|
2024-06-25 08:39:29 +01:00
|
|
|
path,
|
|
|
|
|
name,
|
|
|
|
|
description,
|
|
|
|
|
keywords,
|
|
|
|
|
component,
|
2025-03-09 01:22:23 +00:00
|
|
|
shortDescription,
|
|
|
|
|
longDescription
|
2024-06-25 08:39:29 +01:00
|
|
|
} = options;
|
2024-06-22 22:06:16 +01:00
|
|
|
const Component = component;
|
|
|
|
|
return {
|
2024-06-23 01:26:04 +01:00
|
|
|
type: basePath,
|
2024-06-22 22:06:16 +01:00
|
|
|
path: `${basePath}/${path}`,
|
|
|
|
|
name,
|
2025-02-25 06:17:10 +00:00
|
|
|
icon,
|
2024-06-22 22:06:16 +01:00
|
|
|
description,
|
2024-06-25 08:39:29 +01:00
|
|
|
shortDescription,
|
2024-06-22 22:06:16 +01:00
|
|
|
keywords,
|
|
|
|
|
component: () => {
|
|
|
|
|
return (
|
2024-06-25 19:45:29 +01:00
|
|
|
<ToolLayout
|
|
|
|
|
title={name}
|
|
|
|
|
description={description}
|
2025-02-25 06:17:10 +00:00
|
|
|
icon={icon}
|
2024-06-25 19:45:29 +01:00
|
|
|
type={basePath}
|
|
|
|
|
>
|
2025-03-09 01:22:23 +00:00
|
|
|
<Component title={name} longDescription={longDescription} />
|
2024-06-22 22:06:16 +01:00
|
|
|
</ToolLayout>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|