← Public packages
@kentcdodds/photo-portfolio
A fast, photo-first portfolio site you update by chatting with your agent: galleries, about, contact, and one-step rollback.
Files
import { pickVariant } from '../../src/domain/image-plan.ts'
import type { Photo } from '../../src/domain/types.ts'
import { absoluteUrl, variantUrl, type Site } from '../data/site.ts'
/** Open Graph image for a photo: the JPEG closest to 1200px wide, as an absolute URL. */
export function ogImage(site: Site, photo: Photo | undefined) {
if (!photo) return {}
const variant = pickVariant(photo, 'jpeg', 1200)
if (!variant) return {}
return {
image: {
url: absoluteUrl(site, variantUrl(site, photo, variant)),
width: variant.width,
height: variant.height,
alt: photo.alt,
},
}
}