mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-21 23:36:15 -04:00
refactor(config): removed new tools env config
This commit is contained in:
parent
9d639edf2d
commit
9fa4c26929
3 changed files with 3 additions and 17 deletions
|
@ -53,14 +53,6 @@ export const config = figue({
|
|||
default: false,
|
||||
},
|
||||
},
|
||||
tools: {
|
||||
newTools: {
|
||||
doc: 'Tool names for tools flagged a as new',
|
||||
format: 'array',
|
||||
default: [],
|
||||
env: 'VITE_NEW_TOOLS',
|
||||
},
|
||||
},
|
||||
showBanner: {
|
||||
doc: 'Show the banner',
|
||||
format: 'boolean',
|
||||
|
|
|
@ -8,4 +8,5 @@ export const tool = defineTool({
|
|||
keywords: ['benchmark', 'builder', 'execution', 'duration', 'mean', 'variance'],
|
||||
component: () => import('./benchmark-builder.vue'),
|
||||
icon: SpeedFilled,
|
||||
createdAt: new Date('2023-04-05'),
|
||||
});
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
import { config } from '@/config';
|
||||
import { isAfter, subWeeks } from 'date-fns';
|
||||
import type { Tool } from './tools.types';
|
||||
|
||||
type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
||||
|
||||
export function defineTool(
|
||||
tool: WithOptional<Tool, 'isNew'>,
|
||||
{ newTools }: { newTools: string[] } = { newTools: config.tools.newTools },
|
||||
) {
|
||||
const isInNewToolConfig = newTools.includes(tool.name);
|
||||
const isRecentTool = tool.createdAt ? isAfter(tool.createdAt, subWeeks(new Date(), 2)) : false;
|
||||
|
||||
const isNew = isInNewToolConfig || isRecentTool;
|
||||
export function defineTool(tool: WithOptional<Tool, 'isNew'>) {
|
||||
const isNew = tool.createdAt ? isAfter(tool.createdAt, subWeeks(new Date(), 2)) : false;
|
||||
|
||||
return {
|
||||
isNew,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue