@@ -6,6 +6,8 @@ import { A, H3, P } from '~/common/styleguide';
66import { type IconProps } from '~/components/Icons' ;
77import LoadingContent from '~/components/Library/LoadingContent' ;
88import { type LibraryType , type Query } from '~/types' ;
9+ import { POPULAR_QUERY_BASE } from '~/util/Constants' ;
10+ import { TimeRange } from '~/util/datetime' ;
911import tw from '~/util/tailwind' ;
1012import urlWithQuery from '~/util/urlWithQuery' ;
1113
@@ -16,27 +18,12 @@ const LibraryWithLoading = dynamic(() => import('~/components/Library'), {
1618type Props = {
1719 data : LibraryType [ ] ;
1820 title : string ;
19- filter : ( library : LibraryType ) => boolean ;
2021 icon ?: FunctionComponent < IconProps > ;
21- count ?: number ;
2222 queryParams ?: Query ;
2323} ;
2424
25- const UPDATED_IN = 1000 * 60 * 60 * 24 * 90 ; // 90 days
26- const DEFAULT_PARAMS : Query = {
27- wasRecentlyUpdated : 'true' ,
28- isMaintained : 'true' ,
29- order : 'popularity' ,
30- } ;
31-
32- export default function ExploreSection ( {
33- data,
34- title,
35- filter,
36- icon,
37- count = 4 ,
38- queryParams = { [ title . toLowerCase ( ) ] : true } ,
39- } : Props ) {
25+ const UPDATED_IN = 1000 * TimeRange . MONTH * 3 ;
26+ export default function ExploreSection ( { data, title, icon, queryParams } : Props ) {
4027 const hashLink = title . replace ( / \s / g, '' ) . toLowerCase ( ) ;
4128
4229 return (
@@ -51,12 +38,16 @@ export default function ExploreSection({
5138 { title }
5239 </ A >
5340 </ H3 >
54- < View style = { tw `flex-1 flex-row flex-wrap pt-3` } >
55- { renderLibs ( data . filter ( filter ) , count ) }
56- </ View >
41+ < View style = { tw `flex-1 flex-row flex-wrap pt-3` } > { renderLibs ( data ) } </ View >
5742 < P style = { tw `px-6 pb-6 pt-2 text-sm font-light text-secondary` } >
5843 Want to see more? Check out other{ ' ' }
59- < A href = { urlWithQuery ( '/packages' , { ...queryParams , ...DEFAULT_PARAMS } ) } target = "_self" >
44+ < A
45+ href = { urlWithQuery ( '/packages' , {
46+ [ title . toLowerCase ( ) ] : true ,
47+ ...queryParams ,
48+ ...POPULAR_QUERY_BASE ,
49+ } ) }
50+ target = "_self" >
6051 { title } libraries
6152 </ A > { ' ' }
6253 in the directory!
@@ -65,11 +56,10 @@ export default function ExploreSection({
6556 ) ;
6657}
6758
68- function renderLibs ( list : LibraryType [ ] , count = 4 ) {
59+ function renderLibs ( list : LibraryType [ ] ) {
6960 const now = Date . now ( ) ;
7061 return list
7162 . filter ( ( { github } ) => now - new Date ( github . stats . updatedAt ) . getTime ( ) < UPDATED_IN )
72- . splice ( 0 , count )
7363 . map ( ( item : LibraryType , index : number ) => (
7464 < LibraryWithLoading
7565 key = { `explore-item-${ index } -${ item . github . name } ` }
0 commit comments