@@ -9,7 +9,6 @@ import { LibraryCategoryModel } from "@/features/libraries/models/library-catego
99import { DATA_PATH } from "@/libs/config/project-paths.constants" ;
1010import { DEFAULT_LANGUAGE_CODE } from "@/features/localization/localization.config" ;
1111import { getLibrariesDictionary } from "@/features/localization/services/language-dictionary.service" ;
12- import { LIBRARIES_FILTER_DEFAULT_VALUE } from "@/libs/config/project.constants" ;
1312import { StructuredData } from "@/features/seo/components/structured-data.component" ;
1413import { generateArticleStructuredData } from "@/features/seo/services/structured-data.service" ;
1514import { PageMetadataProps } from "@/features/common/models/page-metadata.props" ;
@@ -18,11 +17,13 @@ import { generatePageMetadata } from "@/libs/metadata/metadata.service";
1817import { createUrlPath } from "@/libs/utils/path.utils" ;
1918import { siteTree } from "@/features/seo/site-tree" ;
2019import { 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" ;
2122
2223export async function generateMetadata ( {
2324 params : { language } ,
2425} : PageMetadataProps ) : Promise < Metadata > {
25- const dictionary = getLibrariesDictionary ( language ) ;
26+ const dictionary : LibrariesDictionaryModel = getLibrariesDictionary ( language ) ;
2627
2728 return generatePageMetadata ( {
2829 languageCode : language ,
@@ -37,7 +38,8 @@ export default function Libraries({
3738} : {
3839 params : { language : string } ;
3940 searchParams ?: {
40- filter ?: string ;
41+ programming_language ?: string ;
42+ algorithm ?: keyof LibraryModel [ "support" ] ;
4143 } ;
4244} ) {
4345 const librariesDictionary = getLibrariesDictionary ( languageCode ) ;
@@ -47,20 +49,41 @@ export default function Libraries({
4749 encoding : "utf-8" ,
4850 } ) ;
4951
50- const query : string | null = searchParams ?. filter || "" ;
52+ const programmingLanguage = searchParams ?. programming_language ?? "" ;
53+ const algorithm = searchParams ?. algorithm ;
54+ const query = programmingLanguage !== "" ? programmingLanguage : algorithm ?? "" ;
5155 const dictionary = JSON . parse ( source ) as LibraryDictionaryModel ;
5256
5357 const categoryOptions : { id : string ; name : string } [ ] = Object . values (
54- dictionary ,
58+ dictionary
5559 ) . map ( ( library ) => ( {
5660 id : library . id ,
5761 name : library . name ,
5862 } ) ) ;
5963
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 ] ]
6273 : Object . values ( dictionary ) ;
6374
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+
6487 return (
6588 < >
6689 < StructuredData
@@ -166,11 +189,12 @@ export default function Libraries({
166189 languageCode = { languageCode }
167190 query = { query || librariesDictionary . filterPicker . defaultValue . value }
168191 categoryOptions = { categoryOptions }
192+ algorithmOptions = { algorithmOptions }
169193 dictionary = { librariesDictionary }
170194 />
171195 < LibraryResultsComponent
172196 languageCode = { languageCode }
173- categories = { categories }
197+ categories = { filteredCategories }
174198 dictionary = { librariesDictionary }
175199 />
176200 < Auth0CtaComponent
0 commit comments