Skip to content

Commit

Permalink
Update query in blog index
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina committed Aug 30, 2024
1 parent 8749033 commit 723be82
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/pages/blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import { Layout } from "../components/layout";
import React from "react";

function BlogCard({
slug,
frontmatter,
parent,
}: Queries.BlogEntriesQuery["allMarkdownRemark"]["nodes"][number]): JSX.Element {
}: Queries.BlogEntriesQuery["allBlog"]["nodes"][number]): JSX.Element {
const title = frontmatter?.title ?? "無題";
const slug = (parent as { name?: string })?.name!;
return (
<HStack borderColor="shadowed" borderRightWidth="1px" borderBottomWidth="2px">
<Avatar as={GatsbyLink} flex="0 0 sm" name={title} to={`/blog/${slug}`} />
Expand All @@ -46,32 +45,27 @@ function BlogCard({

export const query = graphql`
query BlogEntries {
allMarkdownRemark(sort: { frontmatter: { date: ASC } }) {
allBlog {
nodes {
id
slug
frontmatter {
title
date
author
authorId
}
parent {
... on File {
name
}
}
}
}
}
`;

export default function Blog({ data }: PageProps<Queries.BlogEntriesQuery>) {
const blogs = data.allMarkdownRemark.nodes;
const blogs = data.allBlog.nodes;
return (
<Layout title="ブログ">
<SimpleGrid gap={4} columns={1}>
{blogs.map((blog) => (
<BlogCard key={blog.id} {...blog} />
<BlogCard key={blog.slug} {...blog} />
))}
</SimpleGrid>
</Layout>
Expand Down

0 comments on commit 723be82

Please sign in to comment.