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 Tag from '../../atoms/Tag'
|
|
|
|
import { useSiteMetadata } from '../../../hooks/use-site-metadata'
|
2021-03-14 01:34:04 +01:00
|
|
|
import {
|
|
|
|
entryMeta,
|
|
|
|
byline,
|
|
|
|
by,
|
|
|
|
type as styleType,
|
|
|
|
tags as styleTags
|
|
|
|
} from './Meta.module.css'
|
2019-12-14 15:46:43 +01:00
|
|
|
import { Post } from '../../../@types/Post'
|
2019-11-08 15:31:43 +01:00
|
|
|
import shortid from 'shortid'
|
2021-03-01 00:03:39 +01:00
|
|
|
import PostDate from '../../molecules/PostDate'
|
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()
|
2021-02-28 04:50:05 +01:00
|
|
|
const { author, updated, tags } = post.frontmatter
|
|
|
|
const { date, type } = post.fields
|
2018-07-19 02:22:01 +02:00
|
|
|
|
|
|
|
return (
|
2021-03-14 01:34:04 +01:00
|
|
|
<footer className={entryMeta}>
|
|
|
|
<div className={byline}>
|
|
|
|
<span className={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>
|
|
|
|
|
2021-03-01 00:03:39 +01:00
|
|
|
<PostDate date={date} updated={updated} />
|
2018-07-19 02:22:01 +02:00
|
|
|
|
2018-11-08 17:43:40 +01:00
|
|
|
{type && type === 'photo' && (
|
2021-03-14 01:34:04 +01:00
|
|
|
<div className={styleType}>
|
2018-11-08 17:43:40 +01:00
|
|
|
<Link to={`/${slugify(type)}s/`}>{type}s</Link>
|
|
|
|
</div>
|
|
|
|
)}
|
2018-07-19 02:22:01 +02:00
|
|
|
|
|
|
|
{tags && (
|
2021-03-14 01:34:04 +01:00
|
|
|
<div className={styleTags}>
|
2019-10-02 13:35:50 +02:00
|
|
|
{tags.map((tag: string) => {
|
2020-07-19 13:31:27 +02:00
|
|
|
const url = `/archive/${slugify(tag)}/`
|
2019-11-08 15:31:43 +01:00
|
|
|
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>
|
|
|
|
)
|
|
|
|
}
|