@@ -47,20 +47,29 @@ const formatContext = (tokens: number) => {
4747
4848const parameterLabels = PARAMETER_LABELS as Record < StandardParameter , string > ;
4949
50- export function ModelDetailPage ( ) {
50+ interface ModelDetailPageProps {
51+ initialModel : Model | null ;
52+ }
53+
54+ export function ModelDetailPage ( { initialModel } : ModelDetailPageProps ) {
5155 const params = useParams ( ) ;
5256 const router = useRouter ( ) ;
5357 const searchParams = useSearchParams ( ) ;
5458 const modelName = params . modelName as string ;
5559 const decodedModelName = decodeURIComponent ( modelName ) ;
5660
57- const [ model , setModel ] = useState < Model | null > ( null ) ;
58- const [ loading , setLoading ] = useState ( true ) ;
61+ const [ model , setModel ] = useState < Model | null > ( initialModel ) ;
62+ const [ loading , setLoading ] = useState ( ! initialModel ) ;
5963 const [ copiedText , setCopiedText ] = useState < string | null > ( null ) ;
6064
6165 const jawnClient = useJawnClient ( ) ;
6266
6367 useEffect ( ( ) => {
68+ // Skip fetching if we have initial data from SSG
69+ if ( initialModel ) {
70+ return ;
71+ }
72+
6473 async function loadModel ( ) {
6574 try {
6675 const response = await jawnClient . GET (
@@ -86,7 +95,7 @@ export function ModelDetailPage() {
8695 }
8796
8897 loadModel ( ) ;
89- } , [ decodedModelName ] ) ;
98+ } , [ decodedModelName , initialModel , jawnClient ] ) ;
9099
91100 const copyToClipboard = ( text : string , label : string ) => {
92101 navigator . clipboard . writeText ( text ) ;
@@ -144,27 +153,13 @@ export function ModelDetailPage() {
144153 ""
145154 ) ;
146155
147- const cheapestEndpoint = model . endpoints . reduce ( ( min , ep ) => {
148- // Use base pricing or first tier for comparison
149- const epPricing = ep . pricingTiers && ep . pricingTiers . length > 0
150- ? ep . pricingTiers [ 0 ]
151- : ep . pricing ;
152- const minPricing = min . pricingTiers && min . pricingTiers . length > 0
153- ? min . pricingTiers [ 0 ]
154- : min . pricing ;
155-
156- if ( ! epPricing || ! minPricing ) return min ;
157-
158- const epCost = ( epPricing . prompt + epPricing . completion ) / 2 ;
159- const minCost = ( minPricing . prompt + minPricing . completion ) / 2 ;
160- return epCost < minCost ? ep : min ;
161- } ) ;
156+ const firstEndpoint = model . endpoints [ 0 ] ;
162157
163158 const capabilities : { key : string ; label : string ; cost ?: string } [ ] = [ ] ;
164159 // Use first pricing tier for capabilities or base pricing
165- const basePricing = cheapestEndpoint . pricingTiers && cheapestEndpoint . pricingTiers . length > 0
166- ? cheapestEndpoint . pricingTiers [ 0 ]
167- : cheapestEndpoint . pricing ;
160+ const basePricing = firstEndpoint . pricingTiers && firstEndpoint . pricingTiers . length > 0
161+ ? firstEndpoint . pricingTiers [ 0 ]
162+ : firstEndpoint . pricing ;
168163
169164 if ( basePricing && basePricing . audio && basePricing . audio > 0 ) {
170165 capabilities . push ( {
@@ -328,35 +323,20 @@ export function ModelDetailPage() {
328323 return aAvg - bAvg ;
329324 } )
330325 . map ( ( endpoint ) => {
331- const isCheapest = endpoint === cheapestEndpoint ;
332326 // Check for pricing tiers
333327 const pricingArray = endpoint . pricingTiers ;
334328 const hasTiers =
335329 pricingArray && pricingArray . length > 0 ;
336330
337331 return (
338- < TableRow
339- key = { endpoint . provider }
340- className = {
341- isCheapest
342- ? "bg-green-50 dark:bg-green-950/10"
343- : ""
344- }
345- >
332+ < TableRow key = { endpoint . provider } >
346333 < TableCell className = "font-medium" >
347- < div className = "flex items-center gap-2" >
348- < Link
349- href = { `/providers/${ endpoint . providerSlug } ` }
350- className = "hover:underline"
351- >
352- { endpoint . provider }
353- </ Link >
354- { isCheapest && (
355- < span className = "text-xs px-2 py-0.5 rounded-full bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-200" >
356- Cheapest
357- </ span >
358- ) }
359- </ div >
334+ < Link
335+ href = { `/providers/${ endpoint . providerSlug } ` }
336+ className = "hover:underline"
337+ >
338+ { endpoint . provider }
339+ </ Link >
360340 </ TableCell >
361341 < TableCell className = "font-mono text-sm" >
362342 { formatContext ( model . contextLength ) }
0 commit comments