Skip to content

Commit

Permalink
feature: tag in index
Browse files Browse the repository at this point in the history
  • Loading branch information
NobbZ committed Jun 22, 2023
1 parent 7f81817 commit b92102b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/articlepreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as React from "react";
import { Link } from "gatsby";
import { GatsbyImage, ImageDataLike, getImage } from "gatsby-plugin-image";

import { Tag } from "../templates/tags";

type BlogPostNode = Queries.BlogPostsQuery["allMdx"]["nodes"][0];
interface PreviewProps {
node: BlogPostNode;
Expand All @@ -27,16 +29,27 @@ export const Preview = ({ node }: PreviewProps) => {
<div className="w-[140px] p-[5px] shrink-0"></div>
);

const tags = node.frontmatter.tags?.map((tag) =>
tag ? (
<li>
<Tag key={tag} name={tag} />
</li>
) : undefined
);

return (
<article style={{ display: "flex", alignItems: "center" }}>
{teaser}
<div>
<div className="grow-1 w-full">
<h2 className="text-base sm:text-lg md:text-xl">
<Link to={to}>{node.frontmatter.title}</Link>
</h2>
<p className="text-xs md:text-sm">Posted: {node.frontmatter.date}</p>
<p className="hidden md:block md:text-sm">{node.excerpt}</p>
</div>
<div className="w-[100px] shrink-0 text-right">
<ul>{tags}</ul>
</div>
</article>
);
};
1 change: 1 addition & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const query = graphql`
date
title
slug
tags
hero_image_alt
hero_image {
childImageSharp {
Expand Down

0 comments on commit b92102b

Please sign in to comment.