mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-03-13 02:48:56 +01:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
// @flow strict
|
|
import React from 'react';
|
|
import { graphql } from 'gatsby';
|
|
import Layout from '../components/Layout';
|
|
import Post from '../components/Post';
|
|
import { useSiteMetadata } from '../hooks';
|
|
import type { MarkdownRemark } from '../types';
|
|
|
|
type Props = {
|
|
data: {
|
|
markdownRemark: MarkdownRemark
|
|
}
|
|
};
|
|
|
|
const PostTemplate = ({ data }: Props) => {
|
|
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata();
|
|
const { frontmatter } = data.markdownRemark;
|
|
const { title: postTitle, description: postDescription, socialImage } = frontmatter;
|
|
const metaDescription = postDescription !== null ? postDescription : siteSubtitle;
|
|
const socialImageUrl = socialImage ? socialImage['publicURL'] : null;
|
|
|
|
return (
|
|
<Layout title={`${postTitle} - ${siteTitle}`} description={metaDescription} socialImage={socialImageUrl} >
|
|
<Post post={data.markdownRemark} />
|
|
</Layout>
|
|
);
|
|
};
|
|
|
|
export const query = graphql`
|
|
query PostBySlug($slug: String!) {
|
|
markdownRemark(fields: { slug: { eq: $slug } }) {
|
|
id
|
|
html
|
|
fields {
|
|
slug
|
|
tagSlugs
|
|
}
|
|
frontmatter {
|
|
date
|
|
description
|
|
tags
|
|
title
|
|
socialImage {
|
|
publicURL
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export default PostTemplate;
|