@@ -58,7 +58,26 @@ const fetchHubItems = async (repoType) => {
5858 if ( ! response . ok ) {
5959 throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
6060 }
61- const items = await response . json ( ) ;
61+ let items = await response . json ( ) ;
62+
63+ // Step 2: If we are fetching models, get the full details for each one.
64+ if ( repoType === 'models' ) {
65+ const detailPromises = items . map ( item =>
66+ fetch ( `${ API_BASE_URL } models/${ item . id } ` ) . then ( res => {
67+ if ( ! res . ok ) {
68+ console . error ( `Failed to fetch details for ${ item . id } ` ) ;
69+ return null ; // Return null for failed requests
70+ }
71+ return res . json ( ) ;
72+ } )
73+ ) ;
74+
75+ // Wait for all detail requests to complete in parallel.
76+ const detailedItems = await Promise . all ( detailPromises ) ;
77+
78+ // Filter out any models that failed to fetch and assign the detailed list.
79+ items = detailedItems . filter ( Boolean ) ;
80+ }
6281
6382 // Process the data to include metadata and a 'new' flag
6483 const processedItems = items . slice ( 0 , MAX_ITEMS ) . map ( item => {
@@ -113,7 +132,7 @@ const renderHubItemCard = (item, repoType) => {
113132 const prettyName = item . cardData ?. pretty_name || item . cardData ?. model_name || item . cardData ?. title || item . id . split ( '/' ) [ 1 ] ;
114133
115134 // Use the description from cardData, with fallbacks
116- const displayDescription = item . cardData ?. description || item . cardData ?. model_description || item . description || 'No description provided.' ;
135+ const displayDescription = item . cardData ?. description || item . cardData ?. model_description || item . description || 'No description provided.' ;
117136
118137 // Construct the correct URL based on the repository type
119138 let itemUrl = `https://huggingface.co/${ item . id } ` ;
0 commit comments