2020-05-22 14:38:19 +02:00
|
|
|
import React, { ReactElement } from 'react'
|
2018-08-30 22:50:09 +02:00
|
|
|
import { Link } from 'gatsby'
|
2018-07-19 23:04:41 +02:00
|
|
|
import slugify from 'slugify'
|
2019-12-14 15:46:43 +01:00
|
|
|
import Time from '../../atoms/Time'
|
|
|
|
import Tag from '../../atoms/Tag'
|
|
|
|
import { useSiteMetadata } from '../../../hooks/use-site-metadata'
|
|
|
|
import styles from './Meta.module.scss'
|
|
|
|
import { Post } from '../../../@types/Post'
|
2019-11-08 15:31:43 +01:00
|
|
|
import shortid from 'shortid'
|
2018-07-19 02:22:01 +02:00
|
|
|
|
2020-05-22 14:38:19 +02:00
|
|
|
export default function PostMeta({ post }: { post: Post }): ReactElement {
|
2019-10-02 15:32:01 +02:00
|
|
|
const siteMeta = useSiteMetadata()
|
2019-10-12 04:25:15 +02:00
|
|
|
const { author, updated, tags, type } = post.frontmatter
|
2018-09-29 20:09:02 +02:00
|
|
|
const { date } = post.fields
|
2018-07-19 02:22:01 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<footer className={styles.entryMeta}>
|
|
|
|
<div className={styles.byline}>
|
|
|
|
<span className={styles.by}>by</span>
|
2019-10-02 15:32:01 +02:00
|
|
|
<a className="fn" rel="author" href={siteMeta.author.uri}>
|
|
|
|
{author || siteMeta.author.name}
|
2018-07-19 02:22:01 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.time}>
|
2018-07-20 15:23:57 +02:00
|
|
|
{updated && 'published '}
|
2019-10-12 04:25:15 +02:00
|
|
|
<Time date={date} />
|
2018-07-20 15:23:57 +02:00
|
|
|
{updated && ' • updated '}
|
2019-10-12 04:25:15 +02:00
|
|
|
{updated && <Time date={updated} />}
|
2018-07-19 02:22:01 +02:00
|
|
|
</div>
|
|
|
|
|
2018-11-08 17:43:40 +01:00
|
|
|
{type && type === 'photo' && (
|
|
|
|
<div className={styles.type}>
|
|
|
|
<Link to={`/${slugify(type)}s/`}>{type}s</Link>
|
|
|
|
</div>
|
|
|
|
)}
|
2018-07-19 02:22:01 +02:00
|
|
|
|
|
|
|
{tags && (
|
|
|
|
<div className={styles.tags}>
|
2019-10-02 13:35:50 +02:00
|
|
|
{tags.map((tag: string) => {
|
2019-11-08 15:31:43 +01:00
|
|
|
const url = `/tags/${slugify(tag)}/`
|
|
|
|
return <Tag key={shortid.generate()} name={tag} url={url} />
|
2018-09-13 21:51:13 +02:00
|
|
|
})}
|
2018-07-19 02:22:01 +02:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</footer>
|
|
|
|
)
|
|
|
|
}
|