mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-22 13:04:01 +01:00
feat: tools normalized
This commit is contained in:
39
src/tools/defineTool.tsx
Normal file
39
src/tools/defineTool.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import ToolLayout from '../components/ToolLayout';
|
||||
import React, { LazyExoticComponent, JSXElementConstructor } from 'react';
|
||||
|
||||
interface ToolOptions {
|
||||
path: string;
|
||||
component: LazyExoticComponent<JSXElementConstructor<NonNullable<unknown>>>;
|
||||
keywords: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
interface DefinedTool {
|
||||
path: string;
|
||||
name: string;
|
||||
description: string;
|
||||
keywords: string[];
|
||||
component: () => JSX.Element;
|
||||
}
|
||||
|
||||
export const defineTool = (
|
||||
basePath: string,
|
||||
options: ToolOptions
|
||||
): DefinedTool => {
|
||||
const { path, name, description, keywords, component } = options;
|
||||
const Component = component;
|
||||
return {
|
||||
path: `${basePath}/${path}`,
|
||||
name,
|
||||
description,
|
||||
keywords,
|
||||
component: () => {
|
||||
return (
|
||||
<ToolLayout title={name} description={description}>
|
||||
<Component />
|
||||
</ToolLayout>
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
4
src/tools/index.ts
Normal file
4
src/tools/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { stringTools } from '../pages/string/stringTools';
|
||||
import { imageTools } from '../pages/images/imageTools';
|
||||
|
||||
export const tools = [...stringTools, ...imageTools];
|
||||
Reference in New Issue
Block a user