it-tools/packages/app/src/modules/tools/tools.models.ts
2024-10-26 10:54:32 +02:00

18 lines
527 B
TypeScript

export function defineTool(toolDefinition: {
slug: string;
entryFile: string;
currentDirUrl: string;
icon: string;
createdAt: Date;
}) {
const entryFile = new URL(toolDefinition.entryFile, toolDefinition.currentDirUrl).pathname;
const baseGithubUrlPath = entryFile.match(/(\/tools\/.*)$/)?.[1];
const entryFileGithubUrl = `https://github.com/CorentinTh/crucials-tools/blob/main${baseGithubUrlPath}`;
return {
...toolDefinition,
key: toolDefinition.slug,
entryFile,
entryFileGithubUrl,
};
}