This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/website/src/templates/news-post.js

110 lines
3.5 KiB
JavaScript
Raw Normal View History

2021-03-31 17:08:38 +00:00
import * as React from "react";
2021-03-31 22:37:02 +00:00
import { graphql } from "gatsby";
2021-04-01 12:46:00 +00:00
import { Section, SectionTitle } from "../components/Layout";
import { NewsSummary } from "../components/News";
2021-04-07 13:18:40 +00:00
import Seo from "../components/seo";
2021-03-31 22:37:02 +00:00
import { TwitterShareButton, LinkedinShareButton, FacebookShareButton } from "react-share";
import { TwitterSmall, LinkedinSmall, FacebookSmall } from "../components/Icons";
2021-03-31 17:08:38 +00:00
const BlogPostTemplate = ({ data, location }) => {
const post = data.markdownRemark;
2021-04-01 12:46:00 +00:00
// const siteTitle = data.site.siteMetadata?.title || `Title`;
2021-03-31 17:08:38 +00:00
// const { previous, next } = data;
2021-03-31 23:01:32 +00:00
// console.log(post);
2021-03-31 22:37:02 +00:00
2021-03-31 17:08:38 +00:00
return (
2021-04-01 12:46:00 +00:00
<>
2021-04-07 13:18:40 +00:00
<Seo title={post.frontmatter.title} description={post.frontmatter.description || post.excerpt} />
2021-04-08 14:02:01 +00:00
<Section className="bg-white desktop:bg-column" first={true}>
2021-03-31 17:08:38 +00:00
<article className="blog-post" itemScope itemType="http://schema.org/Article">
<SectionTitle itemProp="headline" className="mb-16">
{post.frontmatter.title}
</SectionTitle>
2021-04-01 15:50:16 +00:00
<div className="grid grid-cols-1 desktop:grid-cols-3 gap-y-8 desktop:gap-x-8">
2021-03-31 22:37:02 +00:00
<aside className="space-y-5">
<NewsSummary
avatar={post.frontmatter.avatar}
author={post.frontmatter.author}
date={post.frontmatter.date}
/>
2021-03-31 22:37:02 +00:00
<hr className="text-palette-200" />
<div className="flex items-center">
2021-04-01 12:46:00 +00:00
<div className="text-xs uppercase mr-4">Share</div>
2021-03-31 22:37:02 +00:00
2021-03-31 23:01:32 +00:00
<TwitterShareButton url={location.href} title={post.frontmatter.title} hashtags={[]}>
2021-03-31 23:21:00 +00:00
<TwitterSmall className="fill-current hover:text-palette-400 transition-colors duration-200" />
2021-03-31 22:37:02 +00:00
</TwitterShareButton>
2021-03-31 23:01:32 +00:00
<LinkedinShareButton
url={location.href}
title={post.frontmatter.title}
summary={post.frontmatter.description}
>
2021-03-31 23:21:00 +00:00
<LinkedinSmall className="fill-current hover:text-palette-400 transition-colors duration-200" />
2021-03-31 22:37:02 +00:00
</LinkedinShareButton>
2021-03-31 23:01:32 +00:00
<FacebookShareButton url={location.href} quote={post.frontmatter.title}>
<FacebookSmall className="fill-current hover:text-palette-400 transition-colors duration-200" />
2021-03-31 23:01:32 +00:00
</FacebookShareButton>
2021-03-31 22:37:02 +00:00
</div>
</aside>
2021-04-01 16:29:05 +00:00
<div className="col-span-2 space-y-12">
{post.frontmatter.description && <h2 className="text-lg font-light">{post.frontmatter.description}</h2>}
<section dangerouslySetInnerHTML={{ __html: post.html }} itemProp="articleBody" />
</div>
2021-03-31 22:37:02 +00:00
</div>
2021-03-31 17:08:38 +00:00
</article>
</Section>
2021-04-01 12:46:00 +00:00
</>
2021-03-31 17:08:38 +00:00
);
};
export default BlogPostTemplate;
export const pageQuery = graphql`
query BlogPostBySlug($id: String!, $previousPostId: String, $nextPostId: String) {
site {
siteMetadata {
title
}
}
markdownRemark(id: { eq: $id }) {
id
excerpt(pruneLength: 160)
html
frontmatter {
title
date(formatString: "MMMM DD, YYYY")
description
2021-03-31 22:37:02 +00:00
author
avatar {
childImageSharp {
gatsbyImageData(width: 40, placeholder: BLURRED, formats: [AUTO, WEBP, AVIF])
}
}
2021-03-31 17:08:38 +00:00
}
}
previous: markdownRemark(id: { eq: $previousPostId }) {
fields {
slug
}
frontmatter {
title
}
}
next: markdownRemark(id: { eq: $nextPostId }) {
fields {
slug
}
frontmatter {
title
}
}
}
`;