Skip to content

Commit 5d4427d

Browse files
committed
Adds blog excerpts in index
1 parent 03e3443 commit 5d4427d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/components/BlogPost/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { printIntrospectionSchema } from "graphql"
12
import React from "react"
23
import Marked from "../Marked"
34

@@ -10,6 +11,8 @@ interface Props {
1011
rawMarkdownBody: string
1112
isPermalink: boolean
1213
pageContext: any
14+
excerpt: string
15+
showExcerpt?: true
1316
}
1417

1518
const BlogPost = ({
@@ -20,7 +23,9 @@ const BlogPost = ({
2023
guestBio,
2124
rawMarkdownBody,
2225
isPermalink,
23-
pageContext
26+
pageContext,
27+
excerpt,
28+
showExcerpt
2429
}: Props) => (
2530
<div className="inner-content">
2631
<h1>{isPermalink ? title : <a href={permalink}>{title}</a>}</h1>
@@ -31,7 +36,8 @@ const BlogPost = ({
3136
{guestBio && (
3237
<p className="guestBio">{`This guest article contributed by ${byline}, ${guestBio}.`}</p>
3338
)}
34-
<Marked pageContext={pageContext}>{rawMarkdownBody}</Marked>
39+
40+
{showExcerpt ? <p>{excerpt}</p> : <Marked pageContext={pageContext}>{rawMarkdownBody}</Marked>}
3541
</div>
3642
)
3743

src/pages/blog.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default ({ pageContext, data }: any) => {
2727
{
2828
frontmatter: { title, date, permalink, byline, guestBio },
2929
rawMarkdownBody,
30+
excerpt
3031
}: any,
3132
i
3233
) => (
@@ -40,6 +41,8 @@ export default ({ pageContext, data }: any) => {
4041
rawMarkdownBody={rawMarkdownBody}
4142
isPermalink={false}
4243
pageContext={pageContext}
44+
excerpt={excerpt}
45+
showExcerpt
4346
/>
4447
)
4548
)}
@@ -68,6 +71,7 @@ export const query = graphql`
6871
layout
6972
}
7073
id
74+
excerpt
7175
rawMarkdownBody
7276
}
7377
}

0 commit comments

Comments
 (0)