it-tools/src/tools/tool.ts

34 lines
689 B
TypeScript
Raw Normal View History

import { config } from '@/config';
2022-03-31 00:33:29 +02:00
import type { Component } from 'vue';
export interface ITool {
name: string;
path: string;
description: string;
keywords: string[];
component: () => Promise<Component>;
2022-04-04 00:24:45 +02:00
icon: Component;
redirectFrom?: string[];
isNew: boolean;
2022-04-04 00:24:45 +02:00
}
export interface ToolCategory {
name: string;
icon: Component;
components: ITool[];
2022-03-31 00:33:29 +02:00
}
type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export function defineTool(
tool: WithOptional<ITool, 'isNew'>,
{ newTools }: { newTools: string[] } = { newTools: config.tools.newTools },
) {
const isNew = newTools.includes(tool.name);
return {
isNew,
...tool,
};
}