Skip to content

Commit 1599a0f

Browse files
committed
recall guestBio
1 parent 7a4d0ce commit 1599a0f

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

gatsby-node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
2121
tags: [String!]!
2222
date: Date! @dateformat(formatString: "YYYY-MM-DD")
2323
authors: [String!]!
24+
guestBio: String
2425
}
2526
`);
2627
};
@@ -59,6 +60,7 @@ exports.onCreateNode = async ({
5960
.split(',')
6061
.map(name => name.trim())
6162
.filter(Boolean),
63+
guestBio: node.frontmatter.guestBio ?? null,
6264
};
6365

6466
createNode({

src/components/BlogPost/index.tsx

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const fragments = graphql`
99
date
1010
authors
1111
tags
12+
guestBio
1213
}
1314
`;
1415

@@ -18,24 +19,31 @@ interface Props {
1819

1920
const BlogPost: React.FC<Props> = ({
2021
post,
21-
}) => (
22-
<div className="inner-content">
23-
<h1>{post.title}</h1>
24-
25-
<p>
26-
{new Date(post.date).toLocaleDateString()} by {post.authors.join(', ')}
27-
</p>
28-
29-
<div className="tag-wrapper">
30-
{post.tags.map(tag => (
31-
<span key={tag} className="tag">
32-
<Link to={`/tags/${tag}/`}>{tag}</Link>
33-
</span>
34-
))}
35-
</div>
22+
}) => {
23+
const byline = post.authors.join(', ')
24+
return (
25+
<div className="inner-content">
26+
<h1>{post.title}</h1>
27+
28+
<p>
29+
{new Date(post.date).toLocaleDateString()} by {byline}
30+
</p>
31+
32+
<div className="tag-wrapper">
33+
{post.tags.map(tag => (
34+
<span key={tag} className="tag">
35+
<Link to={`/tags/${tag}/`}>{tag}</Link>
36+
</span>
37+
))}
38+
</div>
3639

37-
<Marked>{post.rawContent}</Marked>
38-
</div>
39-
)
40+
{post.guestBio && (
41+
<p className="guestBio">{`This guest article contributed by ${byline}, ${post.guestBio}.`}</p>
42+
)}
43+
44+
<Marked>{post.rawContent}</Marked>
45+
</div>
46+
)
47+
}
4048

4149
export default BlogPost

0 commit comments

Comments
 (0)