import React, { ReactElement } from 'react' import { graphql } from 'gatsby' import { PageContext } from '../../../@types/Post' import { useSiteMetadata } from '../../../hooks/useSiteMetadata' import Exif from '../../atoms/Exif' import HeadMeta from '../../atoms/HeadMeta' import SchemaOrg from '../../atoms/HeadMeta/SchemaOrg' import { Image } from '../../atoms/Image' import RelatedPosts from '../../molecules/RelatedPosts' import PostActions from './Actions' import PostContent from './Content' import PostLead from './Lead' import PostLinkActions from './LinkActions' import PostMeta from './Meta' import PrevNext from './PrevNext' import PostTitle from './Title' import * as styles from './index.module.css' export default function Post({ data, pageContext: { next, prev } }: { data: Queries.BlogPostBySlugQuery pageContext: { next: { title: string; slug: string } prev: { title: string; slug: string } } }): ReactElement { const { post } = data const { title, image, linkurl, tags, updated } = post.frontmatter const { slug, githubLink, date, type } = post.fields return ( <>
{type === 'article' && } {type === 'photo' && } {image && ( {title} )} {type === 'photo' ? ( image?.fields && ( ) ) : ( )} {type === 'link' && }
) } export function Head({ pageContext, data }: { pageContext: PageContext data: Queries.BlogPostBySlugQuery }): ReactElement { const { siteUrl } = useSiteMetadata() const { excerpt, rawMarkdownBody } = data.post const { title, image, style, updated } = data.post.frontmatter const { date } = data.post.fields const description = excerpt || rawMarkdownBody return ( <> {style && } ) } export const pageQuery = graphql` query BlogPostBySlug($slug: String!) { post: markdownRemark(fields: { slug: { eq: $slug } }) { html excerpt frontmatter { title image { childImageSharp { ...ImageFluid } fields { exif { formatted { iso model fstop shutterspeed focalLength lensModel exposure gps { latitude longitude } } } } } toc author updated tags linkurl style { publicURL } changelog } fields { type slug date githubLink } rawMarkdownBody tableOfContents(maxDepth: 3) } } `