@@ -14,6 +14,7 @@ export const useToolStore = defineStore('tools', () => {
1414
1515 return ( {
1616 ...tool ,
17+ path : tool . path ,
1718 name : t ( `tools.${ toolI18nKey } .title` , tool . name ) ,
1819 description : t ( `tools.${ toolI18nKey } .description` , tool . description ) ,
1920 category : t ( `tools.categories.${ tool . category . toLowerCase ( ) } ` , tool . category ) ,
@@ -23,16 +24,17 @@ export const useToolStore = defineStore('tools', () => {
2324 const toolsByCategory = computed < ToolCategory [ ] > ( ( ) => {
2425 return _ . chain ( tools . value )
2526 . groupBy ( 'category' )
26- . map ( ( components , name ) => ( {
27+ . map ( ( components , name , path ) => ( {
2728 name,
29+ path,
2830 components,
2931 } ) )
3032 . value ( ) ;
3133 } ) ;
3234
3335 const favoriteTools = computed ( ( ) => {
3436 return favoriteToolsName . value
35- . map ( favoriteName => tools . value . find ( ( { name } ) => name === favoriteName ) )
37+ . map ( favoriteName => tools . value . find ( ( { name, path } ) => name === favoriteName || path === favoriteName ) )
3638 . filter ( Boolean ) as ToolWithCategory [ ] ; // cast because .filter(Boolean) does not remove undefined from type
3739 } ) ;
3840
@@ -43,15 +45,16 @@ export const useToolStore = defineStore('tools', () => {
4345 newTools : computed ( ( ) => tools . value . filter ( ( { isNew } ) => isNew ) ) ,
4446
4547 addToolToFavorites ( { tool } : { tool : MaybeRef < Tool > } ) {
46- favoriteToolsName . value . push ( get ( tool ) . name ) ;
48+ favoriteToolsName . value . push ( get ( tool ) . path ) ;
4749 } ,
4850
4951 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 ) ;
5153 } ,
5254
5355 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 ) ;
5558 } ,
5659 } ;
5760} ) ;
0 commit comments