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/pages/news.js

98 lines
2.5 KiB
JavaScript
Raw Normal View History

2021-03-28 16:34:52 +00:00
import * as React from "react";
2021-03-31 22:37:02 +00:00
import { graphql } from "gatsby";
2021-04-01 11:25:37 +00:00
import { GatsbyImage, getImage } from "gatsby-plugin-image";
import Layout, { Section, Label } from "../components/Layout";
import { NewsSummary } from "../components/News";
2021-03-31 22:37:02 +00:00
import Link from "../components/Link";
2021-03-28 16:34:52 +00:00
import SEO from "../components/seo";
2021-03-31 22:37:02 +00:00
const NewsCard = ({ ...props }) => {
2021-04-01 11:25:37 +00:00
console.log(props.frontmatter);
2021-03-31 22:37:02 +00:00
return (
<div className="flex flex-col">
2021-03-31 23:25:33 +00:00
<Link to={props.fields.slug}>
2021-04-01 11:25:37 +00:00
<GatsbyImage image={getImage(props.frontmatter.thumbnail)} />
2021-03-31 23:25:33 +00:00
</Link>
2021-04-01 11:25:37 +00:00
{props.frontmatter.categories && (
<div className="mt-6">
{props.frontmatter.categories.map((category) => (
<Label key={category}>{category}</Label>
))}
</div>
)}
<Link to={props.fields.slug} className="text-xl mt-6">
2021-03-31 22:37:02 +00:00
{props.frontmatter.title}
</Link>
2021-03-31 22:37:02 +00:00
{props.frontmatter.description && (
<Link to={props.fields.slug} className="font-content text-palette-400 mt-4">
{props.frontmatter.description}
</Link>
2021-03-31 22:37:02 +00:00
)}
2021-03-31 22:37:02 +00:00
<div className="mt-6">
<NewsSummary
avatar={props.frontmatter.avatar}
author={props.frontmatter.author}
date={props.frontmatter.date}
/>
2021-03-31 22:37:02 +00:00
</div>
</div>
);
};
const NewsPage = ({ data }) => {
return (
<Layout>
<SEO title="News" />
<Section className="bg-white" first={true}>
<div className="grid grid-cols-1 desktop:grid-cols-3 gap-x-8 gap-y-24">
{data.allMarkdownRemark.edges.map(({ node }) => (
<NewsCard key={node.id} {...node} />
))}
</div>
</Section>
</Layout>
);
};
export const query = graphql`
query NewsQuery {
allMarkdownRemark(
filter: { frontmatter: { hidden: { ne: true } } }
sort: { fields: frontmatter___date, order: DESC }
) {
2021-03-31 22:37:02 +00:00
edges {
node {
id
frontmatter {
title
date(formatString: "MMMM DD, YYYY")
description
author
2021-04-01 11:25:37 +00:00
categories
thumbnail {
childImageSharp {
gatsbyImageData(width: 320, placeholder: BLURRED, formats: [AUTO, WEBP, AVIF])
}
}
2021-03-31 22:37:02 +00:00
avatar {
childImageSharp {
gatsbyImageData(width: 40, placeholder: BLURRED, formats: [AUTO, WEBP, AVIF])
}
}
}
fields {
slug
}
}
}
}
}
`;
2021-03-28 16:34:52 +00:00
export default NewsPage;