2019-07-31 22:05:23 -04:00
|
|
|
// @flow strict
|
2018-11-09 20:08:48 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { graphql } from 'gatsby';
|
|
|
|
import Layout from '../components/Layout';
|
|
|
|
import Post from '../components/Post';
|
2019-05-09 16:57:42 +03:00
|
|
|
import { useSiteMetadata } from '../hooks';
|
2019-05-10 02:15:43 +03:00
|
|
|
import type { MarkdownRemark } from '../types';
|
2018-11-09 20:08:48 +03:00
|
|
|
|
2019-05-10 02:15:43 +03:00
|
|
|
type Props = {
|
2019-07-19 23:38:20 +03:00
|
|
|
data: {
|
|
|
|
markdownRemark: MarkdownRemark
|
|
|
|
}
|
2019-05-10 02:15:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const PostTemplate = ({ data }: Props) => {
|
2019-05-09 16:57:42 +03:00
|
|
|
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
2019-08-25 14:15:37 +02:00
|
|
|
const { frontmatter } = data.markdownRemark;
|
2019-08-25 13:50:36 +02:00
|
|
|
const { title: postTitle, description: postDescription, socialImage } = frontmatter;
|
2018-11-09 20:08:48 +03:00
|
|
|
const metaDescription = postDescription !== null ? postDescription : siteSubtitle;
|
|
|
|
|
|
|
|
return (
|
2019-08-25 12:29:51 +02:00
|
|
|
<Layout title={`${postTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImage} >
|
2018-11-09 20:08:48 +03:00
|
|
|
<Post post={data.markdownRemark} />
|
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const query = graphql`
|
|
|
|
query PostBySlug($slug: String!) {
|
|
|
|
markdownRemark(fields: { slug: { eq: $slug } }) {
|
|
|
|
id
|
|
|
|
html
|
|
|
|
fields {
|
2019-02-07 15:08:12 -05:00
|
|
|
slug
|
2018-11-09 20:08:48 +03:00
|
|
|
tagSlugs
|
|
|
|
}
|
|
|
|
frontmatter {
|
|
|
|
date
|
|
|
|
description
|
|
|
|
tags
|
|
|
|
title
|
2019-08-25 12:29:51 +02:00
|
|
|
socialImage
|
2018-11-09 20:08:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default PostTemplate;
|