gatsby-source-notion-churnotion 1.1.16 → 1.1.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ const constants_1 = require("../constants");
9
9
  const fetchData_1 = require("../util/fetchData");
10
10
  const gatsby_source_filesystem_1 = require("gatsby-source-filesystem");
11
11
  const bookCategoryMap_1 = __importDefault(require("../util/bookCategoryMap"));
12
+ const formatDate_1 = require("../util/formatDate");
12
13
  const getBooks = async ({ bookDatabaseId, reporter, getCache, createNode, createNodeId, getNode, cache, }) => {
13
14
  const databaseUrl = `databases/${bookDatabaseId}/query`;
14
15
  const cacheKey = `booksDatabase-${bookDatabaseId}`;
@@ -62,8 +63,8 @@ const getBooks = async ({ bookDatabaseId, reporter, getCache, createNode, create
62
63
  .update(JSON.stringify(page))
63
64
  .digest(`hex`),
64
65
  },
65
- create_date: page.created_time,
66
- update_date: page.last_edited_time,
66
+ create_date: (0, formatDate_1.useFormatDate)(page.created_time),
67
+ update_date: (0, formatDate_1.useFormatDate)(page.last_edited_time),
67
68
  url: `${constants_1.COMMON_URI}/${constants_1.BOOK_URI}/${slug}`,
68
69
  book_category: book_category,
69
70
  book_image: bookImageNode.id,
@@ -10,6 +10,7 @@ const fetchData_1 = require("../util/fetchData");
10
10
  const processor_1 = require("../util/processor");
11
11
  const slugify_1 = require("../util/slugify");
12
12
  const bookCategoryMap_1 = __importDefault(require("../util/bookCategoryMap"));
13
+ const formatDate_1 = require("../util/formatDate");
13
14
  const getPages = async ({ databaseId, reporter, getCache, actions, createNode, createNodeId, createParentChildLink, getNode, cache, }) => {
14
15
  /**
15
16
  * 데이터베이스 내에 페이지들을 읽어서 재귀적으로 추가하는 서브 메서드드
@@ -56,7 +57,7 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
56
57
  books: [],
57
58
  };
58
59
  await createNode(categoryNode);
59
- const bookRelations = page.properties?.books?.relation || null;
60
+ const bookRelations = page.properties?.book?.relation || null;
60
61
  if (bookRelations) {
61
62
  bookRelations.forEach((relation) => {
62
63
  const bookId = relation.id;
@@ -161,8 +162,8 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
161
162
  book_index: page.properties?.bookIndex?.number || 0,
162
163
  title: title,
163
164
  content: updatedBlocks,
164
- create_date: page.created_time,
165
- update_date: page.last_edited_time,
165
+ create_date: (0, formatDate_1.useFormatDate)(page.created_time),
166
+ update_date: (0, formatDate_1.useFormatDate)(page.last_edited_time),
166
167
  version: page.properties?.version?.number || null,
167
168
  description: page.properties?.description?.rich_text?.[0]?.plain_text ||
168
169
  rawText,
@@ -43,6 +43,7 @@ const createSchemaCustomization = ({ actions }) => {
43
43
  churnotions: [${constants_1.NODE_TYPE.Post}] @link(by: "category", from: "id")
44
44
  url: String!
45
45
  books: [${constants_1.NODE_TYPE.Book}] @link(by: "id")
46
+ childrenNBook: [${constants_1.NODE_TYPE.Book}] @link(by: "book_category", from: "id")
46
47
  }
47
48
 
48
49
  type ${constants_1.NODE_TYPE.Book} implements Node {
@@ -0,0 +1 @@
1
+ export declare const useFormatDate: (dateString: string) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFormatDate = void 0;
4
+ const useFormatDate = (dateString) => {
5
+ const date = new Date(dateString);
6
+ const yyyy = date.getFullYear();
7
+ const mm = String(date.getMonth() + 1).padStart(2, "0");
8
+ const dd = String(date.getDate()).padStart(2, "0");
9
+ return `${yyyy}.${mm}.${dd}`;
10
+ };
11
+ exports.useFormatDate = useFormatDate;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby-source-notion-churnotion",
3
3
  "description": "Gatsby plugin that can connect with One Notion Database RECURSIVELY using official API",
4
- "version": "1.1.16",
4
+ "version": "1.1.18",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",