import {Link, LinkProps} from 'react-router-dom'; import clsx from 'clsx'; import React, {ReactNode, useMemo} from 'react'; import {getBootstrapData} from '@common/core/bootstrap-data/use-backend-bootstrap-data'; import {NewsArticle} from '@app/titles/models/news-article'; interface Props extends Omit { article: NewsArticle; className?: string; children?: ReactNode; color?: 'primary' | 'inherit'; } export function NewsArticleLink({ article, className, children, color = 'inherit', ...linkProps }: Props) { const finalUri = useMemo(() => { return getNewsArticleLink(article); }, [article]); return ( {children ?? article.title} ); } export function getNewsArticleLink( article: NewsArticle, {absolute}: {absolute?: boolean} = {}, ): string { let link = `/news/${article.slug}`; if (absolute) { link = `${getBootstrapData().settings.base_url}${link}`; } return link; }