mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import React from 'react'
|
|
import { Link } from 'react-router-dom'
|
|
import moment from 'moment'
|
|
import styles from './Asset.module.scss'
|
|
import CategoryImage from '../atoms/CategoryImage'
|
|
|
|
const AssetLink = ({ asset, list }: { asset: any; list?: boolean }) => {
|
|
const { metadata } = asset.findServiceByType('Metadata')
|
|
const { base } = metadata
|
|
|
|
return list ? (
|
|
<article className={styles.assetList}>
|
|
<Link to={`/asset/${asset.id}`}>
|
|
<h1>{base.name}</h1>
|
|
<div
|
|
className={styles.date}
|
|
title={`Published on ${base.datePublished}`}
|
|
>
|
|
{moment(base.datePublished, 'YYYYMMDD').fromNow()}
|
|
</div>
|
|
</Link>
|
|
</article>
|
|
) : (
|
|
<article className={styles.asset}>
|
|
<Link to={`/asset/${asset.id}`}>
|
|
{base.categories && (
|
|
<CategoryImage category={base.categories[0]} />
|
|
)}
|
|
<h1>{base.name}</h1>
|
|
<p>{base.description.substring(0, 90)}...</p>
|
|
|
|
<footer className={styles.assetFooter}>
|
|
{base.categories && <div>{base.categories[0]}</div>}
|
|
</footer>
|
|
</Link>
|
|
</article>
|
|
)
|
|
}
|
|
|
|
export default AssetLink
|