import "server-only"; import { existsSync } from "node:fs"; import { join } from "node:path"; import { type Device, getShowcaseAssets, type ShowcaseAssets, } from "@/lib/project-showcase"; const idPattern = /^[a-z0-9-]+$/; /** * Pôster e vídeo gravados em public/videos//, ou `undefined` quando o projeto não tem captura. * Roda no servidor (na geração das páginas): olha se o pôster existe no disco. */ export function getCaseMedia( id: string, device: Device, ): ShowcaseAssets | undefined { if (!idPattern.test(id)) return undefined; const assets = getShowcaseAssets(id, device); const file = join(process.cwd(), "public", assets.poster); return existsSync(file) ? assets : undefined; }