feat(tools): new badge for recently created tools

This commit is contained in:
Corentin Thomasset 2022-06-01 23:52:21 +02:00
parent ac89490794
commit 11720e6cde
No known key found for this signature in database
GPG key ID: DBD997E935996158
33 changed files with 320 additions and 100 deletions

View file

@ -1,3 +1,4 @@
import { config } from '@/config';
import type { Component } from 'vue';
export interface ITool {
@ -8,6 +9,7 @@ export interface ITool {
component: () => Promise<Component>;
icon: Component;
redirectFrom?: string[];
isNew: boolean;
}
export interface ToolCategory {
@ -15,3 +17,17 @@ export interface ToolCategory {
icon: Component;
components: ITool[];
}
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,
};
}