File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
frontend/src/app/scripts/_components Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,18 @@ export function LatestScripts({ items }: { items: Category[] }) {
3535
3636 const latestScripts = useMemo ( ( ) => {
3737 if ( ! items ) return [ ] ;
38+
3839 const scripts = items . flatMap ( ( category ) => category . scripts || [ ] ) ;
39- return scripts . sort (
40+
41+ // Filter out duplicates by slug
42+ const uniqueScriptsMap = new Map < string , Script > ( ) ;
43+ scripts . forEach ( ( script ) => {
44+ if ( ! uniqueScriptsMap . has ( script . slug ) ) {
45+ uniqueScriptsMap . set ( script . slug , script ) ;
46+ }
47+ } ) ;
48+
49+ return Array . from ( uniqueScriptsMap . values ( ) ) . sort (
4050 ( a , b ) =>
4151 new Date ( b . date_created ) . getTime ( ) - new Date ( a . date_created ) . getTime ( ) ,
4252 ) ;
@@ -49,7 +59,7 @@ export function LatestScripts({ items }: { items: Category[] }) {
4959 const goToPreviousPage = ( ) => {
5060 setPage ( ( prevPage ) => prevPage - 1 ) ;
5161 } ;
52-
62+
5363 const startIndex = ( page - 1 ) * ITEMS_PER_PAGE ;
5464 const endIndex = page * ITEMS_PER_PAGE ;
5565
You can’t perform that action at this time.
0 commit comments