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';
|
2024-06-22 22:06:16 +01:00
|
|
|
|
|
|
|
|
interface ToolOptions {
|
|
|
|
|
path: string;
|
|
|
|
|
component: LazyExoticComponent<JSXElementConstructor<NonNullable<unknown>>>;
|
|
|
|
|
keywords: string[];
|
2024-06-23 01:26:04 +01:00
|
|
|
image?: string;
|
2024-06-22 22:06:16 +01:00
|
|
|
name: string;
|
|
|
|
|
description: string;
|
2024-06-25 08:39:29 +01:00
|
|
|
shortDescription: string;
|
2024-06-22 22:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-22 23:31:00 +01:00
|
|
|
export interface DefinedTool {
|
2024-06-23 01:26:04 +01:00
|
|
|
type: string;
|
2024-06-22 22:06:16 +01:00
|
|
|
path: string;
|
|
|
|
|
name: string;
|
|
|
|
|
description: string;
|
2024-06-25 08:39:29 +01:00
|
|
|
shortDescription: string;
|
2024-06-23 01:26:04 +01:00
|
|
|
image?: string;
|
2024-06-22 22:06:16 +01:00
|
|
|
keywords: string[];
|
|
|
|
|
component: () => JSX.Element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const defineTool = (
|
|
|
|
|
basePath: string,
|
|
|
|
|
options: ToolOptions
|
|
|
|
|
): DefinedTool => {
|
2024-06-25 08:39:29 +01:00
|
|
|
const {
|
|
|
|
|
image,
|
|
|
|
|
path,
|
|
|
|
|
name,
|
|
|
|
|
description,
|
|
|
|
|
keywords,
|
|
|
|
|
component,
|
|
|
|
|
shortDescription
|
|
|
|
|
} = 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,
|
2024-06-23 01:26:04 +01:00
|
|
|
image,
|
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}
|
|
|
|
|
image={image}
|
|
|
|
|
type={basePath}
|
|
|
|
|
>
|
2024-06-22 22:06:16 +01:00
|
|
|
<Component />
|
|
|
|
|
</ToolLayout>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|