@@ -14,6 +14,7 @@ export const useToolStore = defineStore('tools', () => {
14
14
15
15
return ( {
16
16
...tool ,
17
+ path : tool . path ,
17
18
name : t ( `tools.${ toolI18nKey } .title` , tool . name ) ,
18
19
description : t ( `tools.${ toolI18nKey } .description` , tool . description ) ,
19
20
category : t ( `tools.categories.${ tool . category . toLowerCase ( ) } ` , tool . category ) ,
@@ -23,16 +24,17 @@ export const useToolStore = defineStore('tools', () => {
23
24
const toolsByCategory = computed < ToolCategory [ ] > ( ( ) => {
24
25
return _ . chain ( tools . value )
25
26
. groupBy ( 'category' )
26
- . map ( ( components , name ) => ( {
27
+ . map ( ( components , name , path ) => ( {
27
28
name,
29
+ path,
28
30
components,
29
31
} ) )
30
32
. value ( ) ;
31
33
} ) ;
32
34
33
35
const favoriteTools = computed ( ( ) => {
34
36
return favoriteToolsName . value
35
- . map ( favoriteName => tools . value . find ( ( { name } ) => name === favoriteName ) )
37
+ . map ( favoriteName => tools . value . find ( ( { name, path } ) => name === favoriteName || path === favoriteName ) )
36
38
. filter ( Boolean ) as ToolWithCategory [ ] ; // cast because .filter(Boolean) does not remove undefined from type
37
39
} ) ;
38
40
@@ -43,15 +45,16 @@ export const useToolStore = defineStore('tools', () => {
43
45
newTools : computed ( ( ) => tools . value . filter ( ( { isNew } ) => isNew ) ) ,
44
46
45
47
addToolToFavorites ( { tool } : { tool : MaybeRef < Tool > } ) {
46
- favoriteToolsName . value . push ( get ( tool ) . name ) ;
48
+ favoriteToolsName . value . push ( get ( tool ) . path ) ;
47
49
} ,
48
50
49
51
removeToolFromFavorites ( { tool } : { tool : MaybeRef < Tool > } ) {
50
- favoriteToolsName . value = favoriteToolsName . value . filter ( name => get ( tool ) . name !== name ) ;
52
+ favoriteToolsName . value = favoriteToolsName . value . filter ( name => get ( tool ) . name !== name && get ( tool ) . path !== name ) ;
51
53
} ,
52
54
53
55
isToolFavorite ( { tool } : { tool : MaybeRef < Tool > } ) {
54
- return favoriteToolsName . value . includes ( get ( tool ) . name ) ;
56
+ return favoriteToolsName . value . includes ( get ( tool ) . name )
57
+ || favoriteToolsName . value . includes ( get ( tool ) . path ) ;
55
58
} ,
56
59
} ;
57
60
} ) ;
0 commit comments