Skip to content

Commit 408758e

Browse files
committed
chore: 패키지 문제 해결
1 parent 935b8be commit 408758e

File tree

4 files changed

+362
-148
lines changed

4 files changed

+362
-148
lines changed

gatsby-config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ module.exports = {
4646
`gatsby-remark-prismjs`,
4747
`gatsby-remark-copy-linked-files`,
4848
`gatsby-remark-smartypants`,
49-
`gatsby-remark-reading-time`,
5049
`gatsby-remark-emoji`,
5150
],
5251
},

gatsby-node.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
const path = require(`path`);
22
const { createFilePath } = require(`gatsby-source-filesystem`);
3+
const readingTime = require('reading-time');
34

45
exports.createSchemaCustomization = ({ actions }) => {
56
const { createTypes } = actions;
67
const typeDefs = `
78
type MarkdownRemark implements Node {
89
frontmatter: Frontmatter
10+
fields: Fields
911
}
1012
type Frontmatter {
1113
title: String!
1214
date: Date! @dateformat
1315
tags: [String]
1416
}
17+
type Fields {
18+
slug: String!
19+
readingTime: ReadingTime
20+
}
21+
type ReadingTime {
22+
text: String
23+
minutes: Float
24+
time: Int
25+
words: Int
26+
}
1527
`;
1628
createTypes(typeDefs);
1729
};
@@ -90,5 +102,13 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
90102
node,
91103
value,
92104
});
105+
106+
// 읽기 시간 계산 및 필드 추가
107+
const timeToRead = readingTime(node.internal.content);
108+
createNodeField({
109+
name: `readingTime`,
110+
node,
111+
value: timeToRead,
112+
});
93113
}
94114
};

0 commit comments

Comments
 (0)