import GithubIcon from '@assets/images/social-media/github.svg'; import GitlabIcon from '@assets/images/social-media/gitlab.svg'; import { t } from '@lingui/macro'; import { ProjectMeta } from '@ts/types/app'; import { slugify } from '@utils/helpers/slugify'; import useGithubApi from '@utils/hooks/useGithubApi'; import Image from 'next/image'; import { useRouter } from 'next/router'; import styles from './ProjectSummary.module.scss'; const ProjectSummary = ({ title, cover, meta, }: { title: string; cover: string; meta: ProjectMeta; }) => { const { license, repos, technologies } = meta; const { locale } = useRouter(); const { data } = useGithubApi(repos?.github ? repos.github : ''); const getFormattedDate = (date: string) => { const dateOptions: Intl.DateTimeFormatOptions = { day: 'numeric', month: 'long', year: 'numeric', }; return new Date(date).toLocaleDateString(locale, dateOptions); }; return (
{t`${title}
{data && (
{t`Created on`}
{t`${getFormattedDate(data.created_at)}`}
)} {data && (
{t`Last updated on`}
{t`${getFormattedDate(data.updated_at)}`}
)}
{t`License`}
{license}
{technologies && (
{t`Technologies`}
{technologies.map((techno) => (
{techno}
))}
)} {repos && (
{t`Repositories`}
{repos.github && (
Github
)} {repos.gitlab && (
Gitlab
)}
)} {data && repos && (
{t`Popularity`}
{repos.github && (
⭐  {t`${data.stargazers_count} stars on Github`}
)}
)}
); }; export default ProjectSummary;