@@ -2,7 +2,7 @@ import Link from "next/link";
22import { FeaturedTaskCarousel } from "@/components/featured-task-carousel" ;
33import { HomeHeroStats } from "@/components/home-hero-stats" ;
44import { ResourceCard } from "@/components/resource-card" ;
5- import { getIndex , type TaskIndexItem } from "@/lib/task-index" ;
5+ import { getIndex } from "@/lib/task-index" ;
66import {
77 contributeResources ,
88 frameworkHighlights ,
@@ -11,41 +11,7 @@ import {
1111 tutorialResources
1212} from "@/lib/site-content" ;
1313
14- const FIXED_FEATURED_REPOS = [ "T000002-bart" , "T000012-sst" , "T000006-mid" ] as const ;
15- const FIXED_FEATURED_REPO_SET = new Set < string > ( FIXED_FEATURED_REPOS ) ;
16- const RANDOM_FEATURED_COUNT = 2 ;
17-
18- function buildSeed ( seedSource : string ) : number {
19- return Array . from ( seedSource ) . reduce (
20- ( seed , character ) => ( ( seed * 33 ) ^ character . charCodeAt ( 0 ) ) >>> 0 ,
21- 5381
22- ) ;
23- }
24-
25- function seededShuffle < T > ( items : T [ ] , seedSource : string ) : T [ ] {
26- const shuffled = [ ...items ] ;
27- let seed = buildSeed ( seedSource ) ;
28-
29- for ( let index = shuffled . length - 1 ; index > 0 ; index -= 1 ) {
30- seed = ( seed * 1664525 + 1013904223 ) >>> 0 ;
31- const swapIndex = seed % ( index + 1 ) ;
32- [ shuffled [ index ] , shuffled [ swapIndex ] ] = [ shuffled [ swapIndex ] , shuffled [ index ] ] ;
33- }
34-
35- return shuffled ;
36- }
37-
38- function uniqueTasks ( tasks : TaskIndexItem [ ] ) : TaskIndexItem [ ] {
39- const seen = new Set < string > ( ) ;
40-
41- return tasks . filter ( ( task ) => {
42- if ( ! task . repo || seen . has ( task . repo ) ) {
43- return false ;
44- }
45- seen . add ( task . repo ) ;
46- return true ;
47- } ) ;
48- }
14+ const FEATURED_REPOS = [ "T000006-mid" , "T000002-bart" , "T000012-sst" ] as const ;
4915
5016function TapsDiagram ( ) {
5117 return (
@@ -130,18 +96,10 @@ function TapsDiagram() {
13096export default function Page ( ) {
13197 const index = getIndex ( ) ;
13298 const tasks = index . tasks ?? [ ] ;
133- const fixedFeaturedTasks = FIXED_FEATURED_REPOS . map ( ( repo ) =>
99+ const featuredTasks = FEATURED_REPOS . map ( ( repo ) =>
134100 tasks . find ( ( task ) => task . repo === repo )
135- ) . filter ( ( task ) : task is TaskIndexItem => Boolean ( task ) ) ;
136- const randomFeaturedTasks = seededShuffle (
137- tasks . filter ( ( task ) => ! FIXED_FEATURED_REPO_SET . has ( task . repo ) ) ,
138- index . generated_at
139- ) . slice ( 0 , RANDOM_FEATURED_COUNT ) ;
140- const curatedFeaturedTasks = uniqueTasks ( [
141- ...fixedFeaturedTasks ,
142- ...randomFeaturedTasks ,
143- ...tasks
144- ] ) . slice ( 0 , FIXED_FEATURED_REPOS . length + RANDOM_FEATURED_COUNT ) ;
101+ ) . filter ( ( task ) : task is ( typeof tasks ) [ number ] => Boolean ( task ) ) ;
102+ const curatedFeaturedTasks = featuredTasks . length > 0 ? featuredTasks : tasks . slice ( 0 , 3 ) ;
145103
146104 return (
147105 < div className = "space-y-20 pb-8" >
0 commit comments