import { useRouter } from 'next/router'import React from 'react'import CustomLink from 'front/CustomLink'import LikeArticleButton from 'front/LikeArticleButton'import LoadingSpinner from 'front/LoadingSpinner'import Pagination, { PaginationPropsUrlFunc } from 'front/Pagination'import UserLinkWithImage from 'front/UserLinkWithImage'import { AppContext, ArticleIcon, TimeIcon, UserIcon } from 'front'import { articleLimit } from 'front/config'import { formatDate } from 'front/date'import routes from 'front/routes'import { ArticleType } from 'front/types/ArticleType'import { CommentType } from 'front/types/CommentType'import { IssueType } from 'front/types/IssueType'import { TopicType } from 'front/types/TopicType'import { UserType } from 'front/types/UserType'export type ArticleListProps = { articles: (ArticleType & IssueType & TopicType)[]; articlesCount: number; comments?: Comment[]; commentsCount?: number; followed?: boolean; issueArticle?: ArticleType; itemType?: string; loggedInUser?: UserType, page: number; paginationUrlFunc?: PaginationPropsUrlFunc; showAuthor: boolean; what?: string;}const ArticleList = ({ articles, articlesCount, comments, commentsCount, followed=false, itemType='article', issueArticle, loggedInUser, page, paginationUrlFunc, showAuthor, what='all',}: ArticleListProps) => { const router = useRouter(); const { asPath, pathname, query } = router; const { like, follow, tag, uid } = query; let isIssue switch (itemType) { case 'discussion': isIssue = true break case 'topic': showAuthor = false break } if (articles.length === 0) { let message; let voice; if (loggedInUser?.username === uid) { voice = "You have not" } else { voice = "This user has not" } switch (what) { case 'likes': message = `${voice} liked any articles yet.` break case 'user-articles': message = `${voice} published any articles yet.` break case 'all': if (followed) { message = `Follow some users to see their posts here.` } else { message = (<> There are no {isIssue ? 'discussions' : 'articles'} on this {isIssue ? 'article' : 'website'} yet. Why don't you create a new one? >) } break default: message = 'There are no articles matching this search' } return
Articles | :Score | }# | }||||
---|---|---|---|---|---|---|
{article.articleCount} | : | } | {showAuthor && | } {isIssue && | } {formatDate(article.createdAt)} | {formatDate(article.updatedAt)} |