mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-07 14:39:30 -07:00
Simplify constants declaration
This commit is contained in:
@@ -5,3 +5,21 @@ export interface CodeObject {
|
||||
usage?: string;
|
||||
installation?: string;
|
||||
}
|
||||
|
||||
export interface CodeObjectInput {
|
||||
utility?: string;
|
||||
code?: string;
|
||||
usage?: string;
|
||||
installation?: string;
|
||||
}
|
||||
|
||||
export function createCodeObject(code: string, path: string, data: CodeObjectInput): CodeObject {
|
||||
const [category, componentName] = path.split('/');
|
||||
return {
|
||||
cli: `npx jsrepo add https://vue-bits.dev/ui/${category}/${componentName}`,
|
||||
...(data.installation && { installation: data.installation }),
|
||||
...(data.usage && { usage: data.usage }),
|
||||
code,
|
||||
...(data.utility && { utility: data.utility })
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user