@@ -9,7 +9,6 @@ import { LibraryCategoryModel } from "@/features/libraries/models/library-catego
9
9
import { DATA_PATH } from "@/libs/config/project-paths.constants" ;
10
10
import { DEFAULT_LANGUAGE_CODE } from "@/features/localization/localization.config" ;
11
11
import { getLibrariesDictionary } from "@/features/localization/services/language-dictionary.service" ;
12
- import { LIBRARIES_FILTER_DEFAULT_VALUE } from "@/libs/config/project.constants" ;
13
12
import { StructuredData } from "@/features/seo/components/structured-data.component" ;
14
13
import { generateArticleStructuredData } from "@/features/seo/services/structured-data.service" ;
15
14
import { PageMetadataProps } from "@/features/common/models/page-metadata.props" ;
@@ -18,11 +17,13 @@ import { generatePageMetadata } from "@/libs/metadata/metadata.service";
18
17
import { createUrlPath } from "@/libs/utils/path.utils" ;
19
18
import { siteTree } from "@/features/seo/site-tree" ;
20
19
import { getAuth0Dictionary } from "@/features/localization/services/ui-language-dictionary.service" ;
20
+ import { LibraryModel } from "@/features/libraries/models/library.model" ;
21
+ import { LibrariesDictionaryModel } from "@/features/localization/models/libraries-dictionary.model" ;
21
22
22
23
export async function generateMetadata ( {
23
24
params : { language } ,
24
25
} : PageMetadataProps ) : Promise < Metadata > {
25
- const dictionary = getLibrariesDictionary ( language ) ;
26
+ const dictionary : LibrariesDictionaryModel = getLibrariesDictionary ( language ) ;
26
27
27
28
return generatePageMetadata ( {
28
29
languageCode : language ,
@@ -37,7 +38,8 @@ export default function Libraries({
37
38
} : {
38
39
params : { language : string } ;
39
40
searchParams ?: {
40
- filter ?: string ;
41
+ programming_language ?: string ;
42
+ algorithm ?: keyof LibraryModel [ "support" ] ;
41
43
} ;
42
44
} ) {
43
45
const librariesDictionary = getLibrariesDictionary ( languageCode ) ;
@@ -47,20 +49,41 @@ export default function Libraries({
47
49
encoding : "utf-8" ,
48
50
} ) ;
49
51
50
- const query : string | null = searchParams ?. filter || "" ;
52
+ const programmingLanguage = searchParams ?. programming_language ?? "" ;
53
+ const algorithm = searchParams ?. algorithm ;
54
+ const query = programmingLanguage !== "" ? programmingLanguage : algorithm ?? "" ;
51
55
const dictionary = JSON . parse ( source ) as LibraryDictionaryModel ;
52
56
53
57
const categoryOptions : { id : string ; name : string } [ ] = Object . values (
54
- dictionary ,
58
+ dictionary
55
59
) . map ( ( library ) => ( {
56
60
id : library . id ,
57
61
name : library . name ,
58
62
} ) ) ;
59
63
60
- let categories : LibraryCategoryModel [ ] = dictionary [ query ]
61
- ? [ dictionary [ query ] ]
64
+ const algorithmOptions : { value : string ; label : string } [ ] = Object . keys ( Object . values (
65
+ dictionary
66
+ ) [ 0 ] . libs [ 0 ] . support ) . map ( key => ( {
67
+ value : key ,
68
+ label : key . toUpperCase ( )
69
+ } ) )
70
+
71
+ const categories : LibraryCategoryModel [ ] = dictionary [ programmingLanguage ]
72
+ ? [ dictionary [ programmingLanguage ] ]
62
73
: Object . values ( dictionary ) ;
63
74
75
+ const filteredCategories = algorithm
76
+ ? categories . map ( ( category ) => {
77
+ const filteredLibs = category . libs . filter (
78
+ ( lib ) => lib . support [ algorithm ]
79
+ ) ;
80
+ return {
81
+ ...category ,
82
+ libs : filteredLibs ,
83
+ } ;
84
+ } )
85
+ : categories ;
86
+
64
87
return (
65
88
< >
66
89
< StructuredData
@@ -166,11 +189,12 @@ export default function Libraries({
166
189
languageCode = { languageCode }
167
190
query = { query || librariesDictionary . filterPicker . defaultValue . value }
168
191
categoryOptions = { categoryOptions }
192
+ algorithmOptions = { algorithmOptions }
169
193
dictionary = { librariesDictionary }
170
194
/>
171
195
< LibraryResultsComponent
172
196
languageCode = { languageCode }
173
- categories = { categories }
197
+ categories = { filteredCategories }
174
198
dictionary = { librariesDictionary }
175
199
/>
176
200
< Auth0CtaComponent
0 commit comments