Skip to content

Commit a6d81e0

Browse files
committed
refactor: 포스트에서 생성일 대신 발행일 표기하도록 변경 (#68)
Signed-off-by: chayeoi <[email protected]>
1 parent 8499176 commit a6d81e0

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

gatsby-config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports = {
7070
{
7171
serialize: ({ query: { site, allMdx } }) => allMdx.edges.map(edge => Object.assign({}, edge.node.frontmatter, {
7272
description: edge.node.frontmatter.description,
73-
date: edge.node.frontmatter.createdAt,
73+
date: edge.node.frontmatter.publishedAt,
7474
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
7575
guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
7676
custom_elements: [{ 'content:encoded': edge.node.html }],
@@ -79,13 +79,13 @@ module.exports = {
7979
{
8080
allMdx(
8181
limit: 1000,
82-
sort: { fields: [frontmatter___createdAt], order: DESC }
82+
sort: { fields: [frontmatter___publishedAt], order: DESC }
8383
) {
8484
edges {
8585
node {
8686
html
8787
frontmatter {
88-
createdAt
88+
publishedAt
8989
title
9090
description
9191
tags

gatsby-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
2424

2525
const result = await graphql(`
2626
query {
27-
allMdx(sort: { fields: [frontmatter___createdAt], order: DESC }) {
27+
allMdx(sort: { fields: [frontmatter___publishedAt], order: DESC }) {
2828
edges {
2929
node {
3030
id

src/components/post-header.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface Props {
1515
frontmatter: {
1616
title: string;
1717
description: string;
18-
createdAt: string;
18+
publishedAt: string;
1919
updatedAt: string;
2020
tags: string[];
2121
cover?: {
@@ -43,11 +43,11 @@ const PostHeader: React.FC<Props> = ({ frontmatter, tableOfContents }) => {
4343
title,
4444
description,
4545
updatedAt,
46-
createdAt,
46+
publishedAt,
4747
cover,
4848
} = frontmatter
4949

50-
const isModified = updatedAt && createdAt !== updatedAt
50+
const isModified = updatedAt && publishedAt !== updatedAt
5151
const hasCover = Boolean(cover)
5252

5353
const toc = useMemo(() => getTocCreator()(tableOfContents.items, 3), [tableOfContents.items])
@@ -61,8 +61,8 @@ const PostHeader: React.FC<Props> = ({ frontmatter, tableOfContents }) => {
6161
</p>
6262
<ul css={s.dateList}>
6363
<li>
64-
<time dateTime={createdAt}>
65-
{dayjs(createdAt).format('YYYY년 MM월 DD일')}
64+
<time dateTime={publishedAt}>
65+
{dayjs(publishedAt).format('YYYY년 MM월 DD일')}
6666
</time>
6767
{isModified && (
6868
<span>

src/components/post-item.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const PostItem: React.FC<Props> = ({ post }) => {
2121
<h3 css={s.heading}>
2222
{post.node.frontmatter.title}
2323
</h3>
24-
<time css={s.createdAt} dateTime={post.node.frontmatter.createdAt}>
25-
{dayjs(post.node.frontmatter.createdAt).format('YYYY년 MM월 DD일')}
24+
<time css={s.publishedAt} dateTime={post.node.frontmatter.publishedAt}>
25+
{dayjs(post.node.frontmatter.publishedAt).format('YYYY년 MM월 DD일')}
2626
</time>
2727
<p css={s.description}>{post.node.frontmatter.description}</p>
2828
<div
@@ -78,7 +78,7 @@ const s = {
7878
font-weight: 700;
7979
line-height: 1.2;
8080
`,
81-
createdAt: (theme: Theme): SerializedStyles => css`
81+
publishedAt: (theme: Theme): SerializedStyles => css`
8282
display: block;
8383
margin-bottom: 0.5rem;
8484
color: ${theme.palette.text.tertiary};

src/models/Mdx.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface Mdx {
55
title: string;
66
description: string;
77
tags?: string[];
8-
createdAt: string;
8+
publishedAt: string;
99
updatedAt?: string;
1010
cover?: {
1111
publicURL: string;

src/pages/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ export const query = graphql`
7676
title
7777
}
7878
}
79-
allMdx(sort: { fields: [frontmatter___createdAt], order: DESC }) {
79+
allMdx(sort: { fields: [frontmatter___publishedAt], order: DESC }) {
8080
edges {
8181
node {
8282
id
8383
frontmatter {
8484
title
8585
description
8686
tags
87-
createdAt
87+
publishedAt
8888
updatedAt
8989
cover {
9090
publicURL

src/posts/applying-api-cache-using-axios/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Axios를 활용하여 API 캐시 적용하기
33
description: API 캐시는 어떻게 구현할 수 있을까?
4-
createdAt: 2019-09-14 00:00:00
4+
publishedAt: 2019-09-14 00:00:00
55
updatedAt: 2019-09-14 00:00:00
66
tags: [Javascript, 캐시]
77
cover: 'cover.jpg'

src/posts/asynchronous-javascript/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 비동기 Javascript
33
description: 비동기 프로그래밍 with Javascript
4-
createdAt: 2019-01-21 00:00:00
4+
publishedAt: 2019-01-21 00:00:00
55
updatedAt: 2019-01-21 00:00:00
66
tags: [Javascript]
77
cover: 'cover.jpg'

src/templates/blog-post.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface Props {
2626
frontmatter: {
2727
title: string;
2828
description: string;
29-
createdAt: string;
29+
publishedAt: string;
3030
updatedAt: string;
3131
tags: string[];
3232
cover?: {
@@ -90,7 +90,7 @@ const BlogPost: React.FC<Props> = ({ data, location, pageContext }) => {
9090
title,
9191
description,
9292
updatedAt,
93-
createdAt,
93+
publishedAt,
9494
cover,
9595
tags,
9696
} = data.mdx.frontmatter
@@ -106,7 +106,7 @@ const BlogPost: React.FC<Props> = ({ data, location, pageContext }) => {
106106
},
107107
{
108108
property: 'article:published_time',
109-
content: createdAt,
109+
content: publishedAt,
110110
},
111111
{
112112
property: 'article:modified_time',
@@ -116,7 +116,7 @@ const BlogPost: React.FC<Props> = ({ data, location, pageContext }) => {
116116
name: 'keywords',
117117
content: _.join(',', tags),
118118
},
119-
]), [createdAt, tags, updatedAt, data.site.siteMetadata.facebook.author])
119+
]), [publishedAt, tags, updatedAt, data.site.siteMetadata.facebook.author])
120120

121121
return (
122122
<Layout>
@@ -179,7 +179,7 @@ export const query = graphql`
179179
frontmatter {
180180
title
181181
description
182-
createdAt
182+
publishedAt
183183
updatedAt
184184
tags
185185
cover {

0 commit comments

Comments
 (0)