Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/website/src/config/workshop-router-content.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { WorkshopDisplayEntry } from '../content/workshop-display.schema'
import type {
GeneratedExample,
UseCase,
WorkshopModel,
WorkshopModelDetail
} from './models-catalogue'
import { useCasesFor } from './models-catalogue'
import { formForContract } from './workshop-contract'
import { workshopContract } from './workshop-contract-catalog'
import { workshopPromptDefaults } from './workshop-prompt-defaults'
Expand Down Expand Up @@ -140,3 +142,22 @@ export function getRouterWorkshopModelDetail(
): WorkshopModelDetail | undefined {
return detailBySlug.get(routerModelSlugAliases.get(slug) ?? slug)
}

/**
* Resolves a Router API `{provider}/{model}` id (or the legacy catalog id
* some content is filed under, when the two differ) plus its use case to
* that model's canonical `/models/[slug]` href, one hop, without going
* through the redirect a bare `{provider}/{model}` id needs when the same
* id maps to more than one use case's page.
*/
export function getRouterModelHref(
modelId: string,
useCase: UseCase
): string | undefined {
return workshopModels.find(
(model) =>
useCasesFor(model).includes(useCase) &&
(model.routerId === modelId ||
routerContentBySlug.get(model.slug)?.entry.id === modelId)
)?.href
}
4 changes: 2 additions & 2 deletions apps/website/src/pages/platform/router.astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import { routerFaq, routerT } from '../../templates/platform/routerCopy'
description={t('platform.products.models.description', 'en')}
>
<ModelsApiHero locale="en" client:load />
<RouterVideoSection locale="en" client:idle />
<RouterCapabilitiesSection locale="en" />
<RouterMigrationBanner locale="en" client:visible />
<RouterProofStripSection locale="en" />
<ModelsApiGallery locale="en" client:visible />
<RouterCodeSection locale="en" client:visible />
<RouterVideoSection locale="en" client:visible />
<RouterCapabilitiesSection locale="en" />
<RouterProviderCoverageSection locale="en" />
<RouterRoadmapSection locale="en" client:visible />
<FAQSection
Expand Down
4 changes: 2 additions & 2 deletions apps/website/src/pages/zh-CN/platform/router.astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import { routerFaq, routerT } from '../../../templates/platform/routerCopy'
description={t('platform.products.models.description', 'zh-CN')}
>
<ModelsApiHero locale="zh-CN" client:load />
<RouterVideoSection locale="zh-CN" client:idle />
<RouterCapabilitiesSection locale="zh-CN" />
<RouterMigrationBanner locale="zh-CN" client:visible />
<RouterProofStripSection locale="zh-CN" />
<ModelsApiGallery locale="zh-CN" client:visible />
<RouterCodeSection locale="zh-CN" client:visible />
<RouterVideoSection locale="zh-CN" client:visible />
<RouterCapabilitiesSection locale="zh-CN" />
<RouterProviderCoverageSection locale="zh-CN" />
<RouterRoadmapSection locale="zh-CN" client:visible />
<FAQSection
Expand Down
55 changes: 54 additions & 1 deletion apps/website/src/templates/platform/ModelsApiGallery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { render, screen } from '@testing-library/vue'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { nextTick } from 'vue'

import { getRouterModelHref } from '../../config/workshop-router-content'
import { t } from '../../i18n/translations'
import ModelsApiGallery from './ModelsApiGallery.vue'
import type { ModelsGalleryCard } from './modelsGalleryCards'
import { modelsGalleryCards } from './modelsGalleryCards'

describe('ModelsApiGallery', () => {
beforeEach(() => {
Expand All @@ -15,7 +18,6 @@ describe('ModelsApiGallery', () => {

for (const titleKey of [
'cloud.aiModels.card.seedance25',
'cloud.aiModels.card.minimaxH3',
'cloud.aiModels.card.nanoBananaPro',
'cloud.aiModels.card.chatgptImages25',
'cloud.aiModels.card.klingAi30',
Expand All @@ -33,4 +35,55 @@ describe('ModelsApiGallery', () => {
await nextTick()
expect(seedanceClip()).not.toBe(firstClip)
})

it('links a card with a model id to its canonical Models page, not a redirecting short slug', () => {
render(ModelsApiGallery, { props: { locale: 'en' } })

expect(
screen.getByRole('link', {
name: new RegExp(t('cloud.aiModels.card.seedance25', 'en'))
})
).toHaveAttribute(
'href',
'/models/byteplus--seedance-2-5-text-to-video--generate-videos/'
)
})

it('links a model id shared by several use cases to the specific page the card names', () => {
render(ModelsApiGallery, { props: { locale: 'en' } })

expect(
screen.getByRole('link', {
name: new RegExp(t('cloud.aiModels.card.geminiOmniFlash', 'en'))
})
).toHaveAttribute('href', '/models/gemini--omni-1.1-flash--animate-images/')
})

it('bakes in the href the Router catalogue resolves for each card, so the two never drift', () => {
for (const card of modelsGalleryCards) {
if (!card.modelId) continue
expect(card.href).toBe(getRouterModelHref(card.modelId, card.useCase))
}
})

it('renders a card without a model id as a plain, non-linked div', () => {
const cards: ModelsGalleryCard[] = [
{
titleKey: 'cloud.aiModels.card.seedance25',
badgeIcon: '/icons/ai-models/bytedance.svg',
media: [{ src: 'https://media.comfy.org/website/test.webp' }]
}
]

render(ModelsApiGallery, { props: { locale: 'en', cards } })

expect(
screen.queryByRole('link', {
name: new RegExp(t('cloud.aiModels.card.seedance25', 'en'))
})
).not.toBeInTheDocument()
expect(
screen.getByText(t('cloud.aiModels.card.seedance25', 'en'))
).toBeTruthy()
})
})
15 changes: 12 additions & 3 deletions apps/website/src/templates/platform/ModelsApiGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { useIntervalFn } from '@vueuse/core'
import { ref } from 'vue'

import { cn } from '@comfyorg/tailwind-utils'

import type { Locale } from '../../i18n/translations'
import { t } from '../../i18n/translations'
import type { GalleryMedia, ModelsGalleryCard } from './modelsGalleryCards'
Expand Down Expand Up @@ -30,10 +32,17 @@ const isVideo = (media: GalleryMedia) => media.src.endsWith('.webm')
:aria-label="t('platform.modelsGallery.ariaLabel', locale)"
>
<div class="grid grid-cols-2 gap-2 lg:grid-cols-3">
<div
<component
:is="card.modelId ? 'a' : 'div'"
v-for="card in cards"
:key="card.titleKey"
class="relative aspect-square overflow-hidden rounded-3xl bg-black/40"
:href="card.href"
:class="
cn(
'relative block aspect-square overflow-hidden rounded-3xl bg-black/40',
card.modelId && 'cursor-pointer'
)
"
>
<Transition
enter-active-class="transition-opacity duration-700"
Expand Down Expand Up @@ -95,7 +104,7 @@ const isVideo = (media: GalleryMedia) => media.src.endsWith('.webm')
>
{{ t(card.titleKey, locale) }}
</p>
</div>
</component>
</div>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ describe('RouterVideoSection', () => {

expect(video).toBeTruthy()
expect(video.hasAttribute('muted')).toBe(true)
expect(video.hasAttribute('autoplay')).toBe(false)
// The section now sits right below the hero, so it loads eagerly
// (native `autoplay`) instead of waiting on `lazy-autoplay` + scroll.
expect(video.hasAttribute('autoplay')).toBe(true)
})
})
1 change: 0 additions & 1 deletion apps/website/src/templates/platform/RouterVideoSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>()
src="https://media.comfy.org/website/router/router-animatic-v019.mp4"
poster="https://media.comfy.org/website/router/router-animatic-v019-poster.webp"
autoplay
lazy-autoplay
/>
</section>
</template>
67 changes: 48 additions & 19 deletions apps/website/src/templates/platform/modelsGalleryCards.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { UseCase } from '../../config/models-catalogue'
import type { TranslationKey } from '../../i18n/translations'

export interface GalleryMedia {
Expand All @@ -6,20 +7,40 @@ export interface GalleryMedia {
trackSrc?: string
}

export interface ModelsGalleryCard {
type ModelsGalleryCardBase = {
titleKey: TranslationKey
badgeIcon: string
media: GalleryMedia[]
}

/**
* A card with no Models page of its own carries none of these fields; a
* card that links to one carries all three, so the link always names the
* specific use case it demonstrates. `href` is this card's model's
* canonical `/models/[slug]` page for that use case (the same lookup
* `model-page.ts` uses) resolved ahead of time, since this file's cards
* ship to the browser and can't import the server-only Router catalogue
* that resolves it (see `ModelsApiGallery.test.ts`, which checks `href`
* against that catalogue). A Router API `{provider}/{model}` id can have a
* Models page per use case (Gemini Omni 1.1 Flash has three), so `modelId`
* alone cannot say which page a card means.
*/
export type ModelsGalleryCard = ModelsGalleryCardBase &
(
| { modelId: string; useCase: UseCase; href: string }
| { modelId?: undefined; useCase?: undefined; href?: undefined }
)

const SEEDANCE_BASE = 'https://media.comfy.org/website/seedance-2.5'
const MINIMAX_BASE = 'https://media.comfy.org/website/minimax'
const AI_MODELS_BASE = 'https://media.comfy.org/website/cloud/ai-models'

export const modelsGalleryCards: ModelsGalleryCard[] = [
{
titleKey: 'cloud.aiModels.card.seedance25',
badgeIcon: '/icons/ai-models/bytedance.svg',
modelId: 'byteplus/dreamina-seedance-2-5-260628',
useCase: 'generate-videos',
href: '/models/byteplus--seedance-2-5-text-to-video--generate-videos/',
media: [
{
src: `${SEEDANCE_BASE}/city.webm`,
Expand All @@ -35,31 +56,20 @@ export const modelsGalleryCards: ModelsGalleryCard[] = [
}
]
},
{
titleKey: 'cloud.aiModels.card.minimaxH3',
badgeIcon: '/icons/ai-models/minimax.svg',
media: [
{
src: 'https://media.comfy.org/website/minimax-h3/hero-dragon-960.webm'
},
{
src: `${MINIMAX_BASE}/ice-rider.webm`,
posterSrc: `${MINIMAX_BASE}/ice-rider-poster.webp`
},
{
src: `${MINIMAX_BASE}/superhero.webm`,
posterSrc: `${MINIMAX_BASE}/superhero-poster.webp`
}
]
},
{
titleKey: 'cloud.aiModels.card.nanoBananaPro',
badgeIcon: '/icons/ai-models/gemini.svg',
modelId: 'vertexai/gemini-3-pro-image',
useCase: 'generate-images',
href: '/models/vertexai--gemini-3-pro-image--generate-images/',
media: [{ src: `${AI_MODELS_BASE}/nano-banana-pro.webp` }]
},
{
titleKey: 'cloud.aiModels.card.chatgptImages25',
badgeIcon: '/icons/ai-models/openai.svg',
modelId: 'openai/gpt-image-2.5-flare',
useCase: 'generate-images',
href: '/models/openai--gpt-image-2.5-flare--generate-images/',
media: [
{
src: `${AI_MODELS_BASE}/gpt-image-2.webm`,
Expand All @@ -70,6 +80,9 @@ export const modelsGalleryCards: ModelsGalleryCard[] = [
{
titleKey: 'cloud.aiModels.card.klingAi30',
badgeIcon: '/icons/ai-models/kling.svg',
modelId: 'kling/kling-3.0-turbo',
useCase: 'generate-videos',
href: '/models/kling--kling-3.0-turbo-text-to-video--generate-videos/',
media: [
{
src: 'https://media.comfy.org/website/router/kling-3-video.webp'
Expand All @@ -79,10 +92,26 @@ export const modelsGalleryCards: ModelsGalleryCard[] = [
{
titleKey: 'cloud.aiModels.card.flux3',
badgeIcon: '/icons/ai-models/bfl.svg',
modelId: 'bfl/flux-3-video',
useCase: 'generate-videos',
href: '/models/bfl--flux-3-text-to-video--generate-videos/',
media: [
{
src: 'https://media.comfy.org/website/router/flux-3-t2v.webp'
}
]
},
{
titleKey: 'cloud.aiModels.card.geminiOmniFlash',
badgeIcon: '/icons/ai-models/gemini.svg',
modelId: 'gemini/omni-1.1-flash',
useCase: 'animate-images',
href: '/models/gemini--omni-1.1-flash--animate-images/',
media: [
{
src: 'https://media.comfy.org/website/gemini-omni/card-1.webm',
posterSrc: 'https://media.comfy.org/website/gemini-omni/card-1.webp'
}
]
}
]
Loading