Skip to content

Commit

Permalink
fix: display when only date available
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 8, 2020
1 parent ca04845 commit d35bc0b
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions ui/blocks/src/DocumentItem/DocumentShortItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,37 @@ export const DocumentShortItem: FC<DocumentShortItemProps> = ({
reverse,
}) => {
const { tags = [], date, author } = doc || {};
const dateNode =
date || author ? (
<Box variant="documentitem.info.inner">
{date ? (
<Box variant="documentitem.info.date">{`created: ${dateToLocalString(
date,
)}`}</Box>
) : (
''
)}
{author && (
<Box variant="documentitem.info.author">
{date && <Text variant="documentitem.info.comma">,</Text>}
<Text variant="documentitem.info.by">by</Text>
<Link href={getDocPath('author', undefined, config?.pages, author)}>
{author}
</Link>
</Box>
)}
</Box>
) : null;
const dateNode = date ? (
<Box variant="documentitem.info.inner">
{date ? (
<Box variant="documentitem.info.date">{`created: ${dateToLocalString(
date,
)}`}</Box>
) : (
''
)}
{author && (
<Box variant="documentitem.info.author">
{date && <Text variant="documentitem.info.comma">,</Text>}
<Text variant="documentitem.info.by">by</Text>
<Link href={getDocPath('author', undefined, config?.pages, author)}>
{author}
</Link>
</Box>
)}
</Box>
) : null;
const tagsNode = tags.length ? <TagsList tags={tags} /> : null;
return tagsNode && dateNode ? (
return tagsNode || dateNode ? (
<Box variant="documentitem.info.container">
{reverse ? (
<Fragment>
{tagsNode}
{tagsNode || <div />}
{dateNode}
</Fragment>
) : (
<Fragment>
{dateNode}
{dateNode || <div />}
{tagsNode}
</Fragment>
)}
Expand Down

0 comments on commit d35bc0b

Please sign in to comment.