gatsby-source-notion-churnotion 1.0.84 → 1.0.86
Sign up to get free protection for your applications and to get access to all the features.
package/dist/api/getBooks.js
CHANGED
@@ -8,6 +8,7 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
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
|
+
const bookCategoryMap_1 = __importDefault(require("../util/bookCategoryMap"));
|
11
12
|
const getBooks = async ({ bookDatabaseId, reporter, getCache, createNode, createNodeId, getNode, cache, }) => {
|
12
13
|
const databaseUrl = `databases/${bookDatabaseId}/query`;
|
13
14
|
const cacheKey = `booksDatabase-${bookDatabaseId}`;
|
@@ -32,7 +33,12 @@ const getBooks = async ({ bookDatabaseId, reporter, getCache, createNode, create
|
|
32
33
|
const categoryId = page.properties?.category?.relation?.[0]?.id || null;
|
33
34
|
let book_category = null;
|
34
35
|
if (categoryId) {
|
35
|
-
|
36
|
+
const bookCategoryId = createNodeId(`${categoryId}-category`);
|
37
|
+
book_category = bookCategoryId;
|
38
|
+
if (!bookCategoryMap_1.default.has(bookCategoryId)) {
|
39
|
+
bookCategoryMap_1.default.set(bookCategoryId, []);
|
40
|
+
}
|
41
|
+
bookCategoryMap_1.default.get(bookCategoryId).push(nodeId);
|
36
42
|
}
|
37
43
|
const bookImage = page.properties?.bookImage?.files?.[0]?.file.url;
|
38
44
|
const bookImageNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
|
package/dist/api/getPages.js
CHANGED
@@ -9,6 +9,7 @@ const constants_1 = require("../constants");
|
|
9
9
|
const fetchData_1 = require("../util/fetchData");
|
10
10
|
const processor_1 = require("../util/processor");
|
11
11
|
const slugify_1 = require("../util/slugify");
|
12
|
+
const bookCategoryMap_1 = __importDefault(require("../util/bookCategoryMap"));
|
12
13
|
const getPages = async ({ databaseId, reporter, getCache, actions, createNode, createNodeId, createParentChildLink, getNode, cache, }) => {
|
13
14
|
/**
|
14
15
|
* 데이터베이스 내에 페이지들을 읽어서 재귀적으로 추가하는 서브 메서드드
|
@@ -66,6 +67,18 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
66
67
|
parent: categoryNode,
|
67
68
|
child: bookNode,
|
68
69
|
});
|
70
|
+
const updatedBookNode = {
|
71
|
+
...bookNode,
|
72
|
+
book_category: categoryNode.id,
|
73
|
+
internal: {
|
74
|
+
...bookNode.internal,
|
75
|
+
contentDigest: crypto_1.default
|
76
|
+
.createHash(`md5`)
|
77
|
+
.update(JSON.stringify(bookNode))
|
78
|
+
.digest(`hex`),
|
79
|
+
},
|
80
|
+
};
|
81
|
+
createNode(updatedBookNode);
|
69
82
|
reporter.info(`[SUCCESS] Linked Category-Book: ${categoryNode.category_name} -> child: ${bookNode.book_name}`);
|
70
83
|
}
|
71
84
|
});
|
@@ -217,5 +230,38 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
217
230
|
}
|
218
231
|
};
|
219
232
|
await processDatabase(databaseId);
|
233
|
+
// Category - Book Relation Update
|
234
|
+
for (const [categoryId, bookIds] of bookCategoryMap_1.default.entries()) {
|
235
|
+
const categoryNode = getNode(categoryId);
|
236
|
+
if (categoryNode) {
|
237
|
+
for (const bookId of bookIds) {
|
238
|
+
const bookNode = getNode(bookId);
|
239
|
+
if (bookNode) {
|
240
|
+
createParentChildLink({
|
241
|
+
parent: categoryNode,
|
242
|
+
child: bookNode,
|
243
|
+
});
|
244
|
+
const updatedBookNode = {
|
245
|
+
...bookNode,
|
246
|
+
book_category: categoryNode.id,
|
247
|
+
internal: {
|
248
|
+
contentDigest: crypto_1.default
|
249
|
+
.createHash(`md5`)
|
250
|
+
.update(JSON.stringify(bookNode))
|
251
|
+
.digest(`hex`),
|
252
|
+
},
|
253
|
+
};
|
254
|
+
createNode(updatedBookNode);
|
255
|
+
reporter.info(`[SUCCESS] Linked Book to Category: ${bookNode.book_name} -> ${categoryNode.category_name}`);
|
256
|
+
}
|
257
|
+
else {
|
258
|
+
reporter.warn(`[WARNING] Book node not found: ${bookId}`);
|
259
|
+
}
|
260
|
+
}
|
261
|
+
}
|
262
|
+
else {
|
263
|
+
reporter.warn(`[WARNING] Category node not found: ${categoryId}`);
|
264
|
+
}
|
265
|
+
}
|
220
266
|
};
|
221
267
|
exports.getPages = getPages;
|
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.0.
|
4
|
+
"version": "1.0.86",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|