Skip to content

Commit 7cbea83

Browse files
committed
Add footer
1 parent 30504c8 commit 7cbea83

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/components/PostFooter.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
3+
export interface PostFooterProps {
4+
date: string;
5+
}
6+
7+
export function PostFooter({ date }: PostFooterProps) {
8+
return (
9+
<>
10+
<hr />
11+
<p>
12+
<small>
13+
Published on {date}.<br />
14+
Questions? Comments? Corrections? Kudos? Find me on <a href="https://twitter.com/atcb">Twitter</a>.
15+
</small>
16+
</p>
17+
</>
18+
);
19+
}

src/templates/Post.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'katex/dist/katex.min.css';
1313
import { shallowClone } from '../utils/shallowClone';
1414
import SEO from '../components/SEO';
1515
import { ErrorCatcher } from '../components/ErrorCatcher';
16+
import { PostFooter } from '../components/PostFooter';
1617

1718
const renderAst = new RehypeReact({
1819
createElement: React.createElement,
@@ -45,6 +46,7 @@ export interface PostProps {
4546
frontmatter: {
4647
title: string;
4748
lib: import('../utils/typescript/types').Extra[];
49+
date: string;
4850
};
4951
};
5052
};
@@ -64,7 +66,8 @@ export const query = graphql`
6466
htmlAst,
6567
frontmatter {
6668
title,
67-
lib
69+
lib,
70+
date(formatString: "MMMM DD, YYYY")
6871
}
6972
}
7073
}
@@ -254,6 +257,7 @@ function Post({ data, pageContext }: PostProps) {
254257
<EditableContext.Provider value={context}>
255258
<div>{renderAst(data.markdownRemark.htmlAst)}</div>
256259
</EditableContext.Provider>
260+
<PostFooter date={post.frontmatter.date} />
257261
</div>
258262
</Layout>
259263
);

0 commit comments

Comments
 (0)