@@ -15,8 +15,13 @@ export type Dependent = {
1515} ;
1616
1717export const getDependents = prerender ( async ( ) => {
18-
1918 const featuredSites : Dependent [ ] = [
19+ {
20+ name : 'Zipline AI' ,
21+ description : 'Features, context and embeddings for real-time AI/ML' ,
22+ repourl : 'https://zipline.ai/' ,
23+ homepageurl : 'https://github.com/zipline-ai'
24+ } ,
2025 {
2126 name : 'Github Analysis' ,
2227 description : 'Analyze your GitHub repositories and NPM packages' ,
@@ -28,12 +33,6 @@ export const getDependents = prerender(async () => {
2833 description : 'Analyze your Strava activities' ,
2934 repourl : 'https://github.com/techniq/strava-analysis' ,
3035 homepageurl : 'https://strava.techniq.dev'
31- } ,
32- {
33- name : 'Zipline AI' ,
34- description : 'Features, context and embeddings for real-time AI/ML' ,
35- repourl : 'https://zipline.ai/' ,
36- homepageurl : 'https://github.com/zipline-ai'
3736 }
3837 ] ;
3938
@@ -188,19 +187,71 @@ export const getDependents = prerender(async () => {
188187 console . log (
189188 `[getDependents] Step 2 - GraphQL details: ${ ( ( performance . now ( ) - step2Start ) / 1000 ) . toFixed ( 2 ) } s (${ dependents . length } repos, ${ batchPromises . length } batches)`
190189 ) ;
190+
191+ // Step 3: Fetch stars for manually-listed sites (featured, supporters, highlighted)
192+ const step3Start = performance . now ( ) ;
193+ const manualSites = [ ...featuredSites , ...supporterSites , ...highlightedSites ] ;
194+ const githubRepoPattern = / g i t h u b \. c o m \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) / ;
195+ const manualSitesWithRepos = manualSites
196+ . map ( ( site ) => {
197+ const match = site . repourl ?. match ( githubRepoPattern ) ;
198+ return match ? { site, owner : match [ 1 ] , name : match [ 2 ] } : null ;
199+ } )
200+ . filter ( Boolean ) as { site : Dependent ; owner : string ; name : string } [ ] ;
201+
202+ if ( manualSitesWithRepos . length > 0 ) {
203+ const fragments = manualSitesWithRepos
204+ . map (
205+ ( { owner, name } , idx ) =>
206+ `manual${ idx } : repository(owner: ${ JSON . stringify ( owner ) } , name: ${ JSON . stringify ( name ) } ) { stargazerCount }`
207+ )
208+ . join ( '\n' ) ;
209+
210+ try {
211+ const res = await fetch ( 'https://api.github.com/graphql' , {
212+ method : 'POST' ,
213+ headers : githubHeaders ,
214+ body : JSON . stringify ( { query : `{ ${ fragments } }` } )
215+ } ) ;
216+ if ( res . ok ) {
217+ const { data } = await res . json ( ) ;
218+ if ( data ) {
219+ manualSitesWithRepos . forEach ( ( { site } , idx ) => {
220+ const repo = data [ `manual${ idx } ` ] ;
221+ if ( repo ) {
222+ site . stars = repo . stargazerCount ;
223+ }
224+ } ) ;
225+ }
226+ }
227+ } catch ( e ) {
228+ console . error ( '[getDependents] Failed to fetch stars for manual sites:' , e ) ;
229+ }
230+ }
231+ console . log (
232+ `[getDependents] Step 3 - Manual site stars: ${ ( ( performance . now ( ) - step3Start ) / 1000 ) . toFixed ( 2 ) } s (${ manualSitesWithRepos . length } repos)`
233+ ) ;
234+
191235 console . log ( `[getDependents] Total: ${ ( ( performance . now ( ) - totalStart ) / 1000 ) . toFixed ( 2 ) } s` ) ;
192236
193- dependents
194- . sort ( ( a , b ) => ( b . stars ?? 0 ) - ( a . stars ?? 0 ) ) // Sort by stars descending
195- . filter ( ( d ) => featuredSites . some ( ( f ) => f . reponame === d . reponame ) ) // Filter out any featured sites
196- . filter ( ( d ) => supporterSites . some ( ( s ) => s . reponame === d . reponame ) ) ; // Filter out any supporter sites
197- const popularSites = [
198- ...highlightedSites ,
199- ...dependents . filter ( ( d ) => ( d . stars ?? 0 ) >= POPULAR_STAR_THRESHOLD )
200- ] ;
201- const otherSites = dependents . filter (
202- ( d ) => ( d . stars ?? 0 ) >= OTHER_STAR_THRESHOLD && ( d . stars ?? 0 ) < POPULAR_STAR_THRESHOLD
237+ // Build a set of repo URLs and homepage URLs from manually-listed sites for deduplication
238+ const manualUrls = new Set (
239+ manualSites . flatMap ( ( s ) => [ s . repourl , s . homepageurl ] . filter ( Boolean ) )
203240 ) ;
204241
242+ const filteredDependents = dependents
243+ . filter ( ( d ) => ! manualUrls . has ( d . repourl ) && ! manualUrls . has ( d . homepageurl ) )
244+ . sort ( ( a , b ) => ( b . stars ?? 0 ) - ( a . stars ?? 0 ) ) ;
245+
246+ const popularSites = filteredDependents . filter (
247+ ( d ) => ( d . stars ?? 0 ) >= POPULAR_STAR_THRESHOLD
248+ ) ;
249+ const otherSites = [
250+ ...filteredDependents . filter (
251+ ( d ) => ( d . stars ?? 0 ) >= OTHER_STAR_THRESHOLD && ( d . stars ?? 0 ) < POPULAR_STAR_THRESHOLD
252+ ) ,
253+ ...highlightedSites
254+ ] ;
255+
205256 return { featuredSites, supporterSites, popularSites, otherSites } ;
206257} ) ;
0 commit comments