import * as React from "react" import { ReactNode } from "react" import { GatsbyLinkProps, graphql, Link, PageProps } from "gatsby" import Layout from "../../components/organisms/Layout" import { Card, CardContent, CardMedia, Grid, Typography } from "@mui/material" import styled from "@emotion/styled" import { GatsbyImage, getImage } from "gatsby-plugin-image" type PostProps = { size?: "normal" | "highlight" post: Queries.BlogQuery["allMdx"]["edges"][0]["node"] } const Post = ({ size = "normal", post }: PostProps) => { const PostLink = styled((props: { children: ReactNode }) => ( ))` color: inherit; text-decoration: inherit; &:hover { opacity: 0.8; } ` const featuredImage = getImage(post.frontmatter?.featuredImage?.childImageSharp?.gatsbyImageData!) return ( {featuredImage && ( ( )} /> )} {post.frontmatter?.title} {post.excerpt} ) } const Blog = ({ data: { allMdx } }: PageProps) => { const [highlight, ...posts] = allMdx.edges return ( {posts.map(({ node: post }) => ( ))} ) } export const query = graphql` query Blog { allMdx( sort: { fields: [frontmatter___published], order: DESC } filter: { fields: { source: { eq: "posts" } }, frontmatter: { published: { ne: null } } } ) { edges { node { id slug excerpt(pruneLength: 400) frontmatter { title published featuredImage { childImageSharp { gatsbyImageData(height: 200) } } featuredImageAlt } } } } } ` export default Blog