diff --git a/components/teks/teks-kat.js b/components/teks/teks-kat.js new file mode 100644 index 0000000..8540a14 --- /dev/null +++ b/components/teks/teks-kat.js @@ -0,0 +1,69 @@ +import PropTypes from 'prop-types' +import {useRouter} from 'next/router' +import {format} from 'date-fns' +import {fr} from 'date-fns/locale' +import { + Card, + CardActionArea, + CardContent, + CardMedia, + Typography, + Grid +} from '@material-ui/core' +import {makeStyles} from '@material-ui/core/styles' + +const useStyles = makeStyles({ + root: { + maxWidth: 345 + }, + media: { + height: 240, + objectFit: 'contain' + } +}) + +export default function TeksKat({teks}) { + const classes = useStyles() + const router = useRouter() + const noImageUrl = 'https://place-hold.it/140x140?text=Pa%20ni%20imaj' + const {titre, awtis, annee, cover, published_at, slug} = teks + const datPiblikasyon = format(new Date(published_at), 'Pp', {locale: fr}) + + const handleClick = slug => { + router.push(`/teks/${slug}#${slug}`) + } + + return ( + + + handleClick(slug)}> + + + + {titre} + + + {awtis.map(a => a.alias).join()} + + + {annee} + + + Piblikasyon : {datPiblikasyon} + + + + + + ) +} + +TeksKat.propTypes = { + teks: PropTypes.object.isRequired +}