@@ -20,7 +20,7 @@ import { CustomPage } from "@/pages/_app";
20
20
21
21
const Home : CustomPage = ( ) => {
22
22
const router = useRouter ( ) ;
23
- const tag = router . query . tag as string | undefined ;
23
+ const tagQuery = router . query . tag as string | undefined ;
24
24
const appName = getAppName ( ) ;
25
25
const metaDescription = getLabel ( "metaDescription" ) ;
26
26
const chartConfig = getChartConfig ( ) ;
@@ -29,9 +29,28 @@ const Home: CustomPage = () => {
29
29
const rings = getRings ( ) ;
30
30
const quadrants = getQuadrants ( ) ;
31
31
const tags = getTags ( ) ;
32
- const items = getItems ( undefined , true ) . filter (
33
- ( item ) => ! tag || item . tags ?. includes ( tag ) ,
34
- ) ;
32
+
33
+ // Parse active tags from URL, filtering out empty values
34
+ const activeTags = tagQuery ?. split ( "," ) . filter ( Boolean ) ?? [ ] ;
35
+
36
+ // Remove empty tag parameter from URL
37
+ if ( tagQuery === "" ) {
38
+ router . replace ( "/" , undefined , { shallow : true } ) ;
39
+ }
40
+
41
+ // Filter items based on selected tags
42
+ const items = getItems ( undefined , true ) . filter ( ( item ) => {
43
+ // Show all items if no tags are selected
44
+ if ( ! activeTags . length ) return true ;
45
+
46
+ // Handle potentially undefined tags with a default empty array
47
+ const itemTags = item . tags ?? [ ] ;
48
+
49
+ // Show item only if it has all selected tags (AND logic)
50
+ return (
51
+ itemTags . length > 0 && activeTags . every ( ( tag ) => itemTags . includes ( tag ) )
52
+ ) ;
53
+ } ) ;
35
54
36
55
return (
37
56
< >
@@ -65,7 +84,7 @@ const Home: CustomPage = () => {
65
84
return (
66
85
getToggle ( "showTagFilter" ) &&
67
86
tags . length > 0 && (
68
- < Tags key = { section } tags = { tags } activeTag = { tag } />
87
+ < Tags key = { section } tags = { tags } activeTags = { activeTags } />
69
88
)
70
89
) ;
71
90
case "list" :
0 commit comments