import { UploadImageFragment } from "graphql/generated"; import { AppStaticProps } from "graphql/getAppStaticProps"; import { prettySlug } from "helpers/formatters"; import { ImageQuality } from "helpers/img"; import { useSmartLanguage } from "hooks/useSmartLanguage"; import Link from "next/link"; import { Chip } from "./Chip"; import { Img } from "./Img"; interface Props { thumbnail?: UploadImageFragment | string | null | undefined; thumbnailAspectRatio?: string; href: string; pre_title?: string | null | undefined; title: string | null | undefined; subtitle?: string | null | undefined; topChips?: string[]; bottomChips?: string[]; } export function PreviewLine(props: Props): JSX.Element { const { href, thumbnail, pre_title, title, subtitle, topChips, bottomChips, thumbnailAspectRatio, } = props; return (
{thumbnail ? (
) : (
)}
{topChips && topChips.length > 0 && (
{topChips.map((text, index) => ( {text} ))}
)}
{pre_title &&

{pre_title}

} {title && (

{title}

)} {subtitle &&

{subtitle}

}
{bottomChips && bottomChips.length > 0 && (
{bottomChips.map((text, index) => ( {text} ))}
)}
); } interface TranslatedProps extends Omit { translations: | { pre_title?: string | null | undefined; title: string | null | undefined; subtitle?: string | null | undefined; language: string | undefined; }[] | undefined; slug: string; languages: AppStaticProps["languages"]; } export function TranslatedPreviewLine( props: Immutable ): JSX.Element { const { translations = [{ title: props.slug, language: "default" }], slug, languages, } = props; const [selectedTranslation] = useSmartLanguage({ items: translations, languages: languages, languageExtractor: (item) => item.language, }); return ( ); }