gatsby-source-notion-churnotion 1.0.41 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/getPages.js
CHANGED
@@ -40,16 +40,6 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
40
40
|
}
|
41
41
|
const nodeId = createNodeId(`${categoryJsonData.id}-category`);
|
42
42
|
const categoryUrl = `${parentCategoryUrl}/${slug}`;
|
43
|
-
// Find Book
|
44
|
-
const bookRelations = page.properties?.books?.relation || null;
|
45
|
-
const books = [];
|
46
|
-
if (bookRelations) {
|
47
|
-
bookRelations.forEach((relation) => {
|
48
|
-
const bookId = relation.id;
|
49
|
-
const bookNodeId = createNodeId(`${bookId}-book`);
|
50
|
-
books.push(bookNodeId);
|
51
|
-
});
|
52
|
-
}
|
53
43
|
const categoryNode = {
|
54
44
|
id: nodeId,
|
55
45
|
category_name: title,
|
@@ -64,9 +54,25 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
64
54
|
.digest(`hex`),
|
65
55
|
},
|
66
56
|
url: `${constants_1.COMMON_URI}/${constants_1.CATEGORY_URI}${categoryUrl}`,
|
67
|
-
books:
|
57
|
+
books: [],
|
68
58
|
};
|
69
59
|
await createNode(categoryNode);
|
60
|
+
// Find Book
|
61
|
+
const bookRelations = page.properties?.books?.relation || null;
|
62
|
+
if (bookRelations) {
|
63
|
+
bookRelations.forEach((relation) => {
|
64
|
+
const bookId = relation.id;
|
65
|
+
const bookNodeId = createNodeId(`${bookId}-book`);
|
66
|
+
const bookNode = getNode(bookNodeId);
|
67
|
+
if (bookNode) {
|
68
|
+
createParentChildLink({
|
69
|
+
parent: categoryNode,
|
70
|
+
child: bookNode,
|
71
|
+
});
|
72
|
+
reporter.info(`[SUCCESS] Linked Category-Book: ${categoryNode.category_name} -> child: ${bookNode.book_name}`);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
}
|
70
76
|
if (parentCategoryId && categoryNode) {
|
71
77
|
const parentNode = getNode(parentCategoryId); // Gatsby에서 노드를 검색
|
72
78
|
if (parentNode) {
|
@@ -136,7 +142,7 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
136
142
|
}
|
137
143
|
const bookId = page.properties?.book?.relation?.[0]?.id || null;
|
138
144
|
const markdownContent = await connector_1.n2m.pageToMarkdown(page.id);
|
139
|
-
const imageNode = await (0, imageProcessor_1.processBlocks)(markdownContent, actions, getCache, createNodeId, reporter);
|
145
|
+
const imageNode = await (0, imageProcessor_1.processBlocks)(markdownContent, actions, getCache, createNodeId, reporter, createParentChildLink);
|
140
146
|
const gatsbyImageData = {
|
141
147
|
childImageSharp: {
|
142
148
|
gatsbyImageData: imageNode
|
@@ -40,7 +40,7 @@ const createSchemaCustomization = ({ actions }) => {
|
|
40
40
|
children: [${constants_1.NODE_TYPE.Category}!]! @link(by: "parent")
|
41
41
|
churnotions: [${constants_1.NODE_TYPE.Post}] @link(by: "category", from: "id")
|
42
42
|
url: String!
|
43
|
-
books: [${constants_1.NODE_TYPE.Book}] @link(by: "
|
43
|
+
books: [${constants_1.NODE_TYPE.Book}] @link(by: "id", from: "books")
|
44
44
|
}
|
45
45
|
|
46
46
|
type ${constants_1.NODE_TYPE.Book} implements Node {
|
@@ -1,3 +1,8 @@
|
|
1
|
-
import { Actions, GatsbyCache, Reporter } from "gatsby";
|
1
|
+
import { Actions, GatsbyCache, Node, NodeInput, Reporter } from "gatsby";
|
2
2
|
import { MdBlock } from "notion-to-md/build/types";
|
3
|
-
export declare const processBlocks: (blocks: MdBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter
|
3
|
+
export declare const processBlocks: (blocks: MdBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter, createParentChildLink: (this: void, args: {
|
4
|
+
parent: Node;
|
5
|
+
child: NodeInput;
|
6
|
+
}, plugin?: {
|
7
|
+
name: string;
|
8
|
+
}) => void) => Promise<string | null>;
|
@@ -2,10 +2,23 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.processBlocks = void 0;
|
4
4
|
const gatsby_source_filesystem_1 = require("gatsby-source-filesystem");
|
5
|
-
const processBlocks = async (blocks, actions, getCache, createNodeId, reporter) => {
|
5
|
+
const processBlocks = async (blocks, actions, getCache, createNodeId, reporter, createParentChildLink) => {
|
6
6
|
const { createNode } = actions;
|
7
7
|
let thumbnail = null;
|
8
8
|
for (const block of blocks) {
|
9
|
+
const blockNodeId = createNodeId(`${block.blockId}-MdBlock`);
|
10
|
+
const blockNode = {
|
11
|
+
...block,
|
12
|
+
id: blockNodeId,
|
13
|
+
parent: null,
|
14
|
+
children: [],
|
15
|
+
internal: {
|
16
|
+
type: "MdBlock",
|
17
|
+
contentDigest: createNodeId(JSON.stringify(block)),
|
18
|
+
owner: blockNodeId,
|
19
|
+
},
|
20
|
+
};
|
21
|
+
createNode(blockNode);
|
9
22
|
if (block.type === `image` &&
|
10
23
|
typeof block.parent === `string` &&
|
11
24
|
block.parent.includes(`http`)) {
|
@@ -16,12 +29,16 @@ const processBlocks = async (blocks, actions, getCache, createNodeId, reporter)
|
|
16
29
|
try {
|
17
30
|
const fileNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
|
18
31
|
url: imageUrl,
|
19
|
-
parentNodeId:
|
32
|
+
parentNodeId: blockNodeId,
|
20
33
|
getCache,
|
21
34
|
createNode,
|
22
35
|
createNodeId,
|
23
36
|
});
|
24
37
|
if (fileNode) {
|
38
|
+
createParentChildLink({
|
39
|
+
parent: blockNode,
|
40
|
+
child: fileNode,
|
41
|
+
});
|
25
42
|
block.parent = fileNode.id;
|
26
43
|
if (!thumbnail)
|
27
44
|
thumbnail = fileNode.id;
|
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.44",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|