diff --git a/apps/website/src/config/workshop-router-content.ts b/apps/website/src/config/workshop-router-content.ts index e87f69dadf1..e1d7ef1e737 100644 --- a/apps/website/src/config/workshop-router-content.ts +++ b/apps/website/src/config/workshop-router-content.ts @@ -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' @@ -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 +} diff --git a/apps/website/src/pages/platform/router.astro b/apps/website/src/pages/platform/router.astro index 72d65c84a51..45ba9040c18 100644 --- a/apps/website/src/pages/platform/router.astro +++ b/apps/website/src/pages/platform/router.astro @@ -22,12 +22,12 @@ import { routerFaq, routerT } from '../../templates/platform/routerCopy' description={t('platform.products.models.description', 'en')} > + + - - + + - - { beforeEach(() => { @@ -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', @@ -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() + }) }) diff --git a/apps/website/src/templates/platform/ModelsApiGallery.vue b/apps/website/src/templates/platform/ModelsApiGallery.vue index 3a1ebb77cea..41552c0e1b7 100644 --- a/apps/website/src/templates/platform/ModelsApiGallery.vue +++ b/apps/website/src/templates/platform/ModelsApiGallery.vue @@ -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' @@ -30,10 +32,17 @@ const isVideo = (media: GalleryMedia) => media.src.endsWith('.webm') :aria-label="t('platform.modelsGallery.ariaLabel', locale)" >
-
media.src.endsWith('.webm') > {{ t(card.titleKey, locale) }}

-
+
diff --git a/apps/website/src/templates/platform/RouterVideoSection.test.ts b/apps/website/src/templates/platform/RouterVideoSection.test.ts index 4351054db1d..2fba6da5bdd 100644 --- a/apps/website/src/templates/platform/RouterVideoSection.test.ts +++ b/apps/website/src/templates/platform/RouterVideoSection.test.ts @@ -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) }) }) diff --git a/apps/website/src/templates/platform/RouterVideoSection.vue b/apps/website/src/templates/platform/RouterVideoSection.vue index 2d76a6140f6..e40665c0419 100644 --- a/apps/website/src/templates/platform/RouterVideoSection.vue +++ b/apps/website/src/templates/platform/RouterVideoSection.vue @@ -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 /> diff --git a/apps/website/src/templates/platform/modelsGalleryCards.ts b/apps/website/src/templates/platform/modelsGalleryCards.ts index 65cd62370c3..bd85cc21544 100644 --- a/apps/website/src/templates/platform/modelsGalleryCards.ts +++ b/apps/website/src/templates/platform/modelsGalleryCards.ts @@ -1,3 +1,4 @@ +import type { UseCase } from '../../config/models-catalogue' import type { TranslationKey } from '../../i18n/translations' export interface GalleryMedia { @@ -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`, @@ -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`, @@ -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' @@ -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' + } + ] } ]