gatsby-source-notion-churnotion 1.0.46 → 1.0.48
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/getPages.js +2 -11
- package/dist/util/imageProcessor.d.ts +2 -2
- package/dist/util/imageProcessor.js +23 -24
- package/package.json +2 -1
package/dist/api/getPages.js
CHANGED
@@ -9,7 +9,6 @@ const constants_1 = require("../constants");
|
|
9
9
|
const fetchData_1 = require("../util/fetchData");
|
10
10
|
const imageProcessor_1 = require("../util/imageProcessor");
|
11
11
|
const slugify_1 = require("../util/slugify");
|
12
|
-
const connector_1 = require("./connector");
|
13
12
|
const getPages = async ({ databaseId, reporter, getCache, actions, createNode, createNodeId, createParentChildLink, getNode, }) => {
|
14
13
|
/**
|
15
14
|
* 데이터베이스 내에 페이지들을 읽어서 재귀적으로 추가하는 서브 메서드드
|
@@ -141,22 +140,14 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
141
140
|
});
|
142
141
|
}
|
143
142
|
const bookId = page.properties?.book?.relation?.[0]?.id || null;
|
144
|
-
const
|
145
|
-
const imageNode = await (0, imageProcessor_1.processBlocks)(markdownContent, actions, getCache, createNodeId, reporter);
|
146
|
-
const gatsbyImageData = {
|
147
|
-
childImageSharp: {
|
148
|
-
gatsbyImageData: imageNode
|
149
|
-
? `childImageSharp___NODE___${imageNode}`
|
150
|
-
: null,
|
151
|
-
},
|
152
|
-
};
|
143
|
+
const imageNode = await (0, imageProcessor_1.processBlocks)(pageData.results, actions, getCache, createNodeId, reporter);
|
153
144
|
const postNode = {
|
154
145
|
id: nodeId,
|
155
146
|
category: parentCategoryId,
|
156
147
|
book: getNode(`${bookId}-book`),
|
157
148
|
book_index: page.properties?.bookIndex?.number || 0,
|
158
149
|
title: title,
|
159
|
-
content:
|
150
|
+
content: pageData.results,
|
160
151
|
create_date: page.created_time,
|
161
152
|
update_date: page.last_edited_time,
|
162
153
|
version: page.properties?.version?.number || null,
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { Actions, GatsbyCache, Reporter } from "gatsby";
|
2
|
-
import {
|
3
|
-
export declare const processBlocks: (blocks:
|
2
|
+
import { BaseContentBlock } from "notion-types";
|
3
|
+
export declare const processBlocks: (blocks: BaseContentBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter) => Promise<string | null>;
|
@@ -2,36 +2,35 @@
|
|
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
|
+
// Type Guard
|
6
|
+
function isImageBlock(block) {
|
7
|
+
return block.type === "image" && "image" in block;
|
8
|
+
}
|
5
9
|
const processBlocks = async (blocks, actions, getCache, createNodeId, reporter) => {
|
6
10
|
const { createNode } = actions;
|
7
11
|
let thumbnail = null;
|
8
12
|
for (const block of blocks) {
|
9
|
-
if (block
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
block.parent = fileNode.id;
|
26
|
-
if (!thumbnail)
|
27
|
-
thumbnail = fileNode.id;
|
28
|
-
reporter.info(`[SUCCESS] Image processed: ${fileNode.id}`);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
catch (error) {
|
32
|
-
reporter.warn(`[WARNING] Failed to download image: ${imageUrl}`);
|
13
|
+
if (isImageBlock(block) && block?.image?.file?.url) {
|
14
|
+
const imageUrl = block.image.file.url;
|
15
|
+
reporter.info(`[Image] got image > ${imageUrl}`);
|
16
|
+
try {
|
17
|
+
const fileNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
|
18
|
+
url: imageUrl,
|
19
|
+
parentNodeId: block.id,
|
20
|
+
getCache,
|
21
|
+
createNode,
|
22
|
+
createNodeId,
|
23
|
+
});
|
24
|
+
if (fileNode) {
|
25
|
+
block.image.file.url = fileNode.id;
|
26
|
+
if (!thumbnail)
|
27
|
+
thumbnail = fileNode.id;
|
28
|
+
reporter.info(`[SUCCESS] Image processed: ${fileNode.id}`);
|
33
29
|
}
|
34
30
|
}
|
31
|
+
catch (error) {
|
32
|
+
reporter.warn(`[WARNING] Failed to download image: ${imageUrl}`);
|
33
|
+
}
|
35
34
|
}
|
36
35
|
}
|
37
36
|
return thumbnail;
|
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.48",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|
@@ -42,6 +42,7 @@
|
|
42
42
|
"gatsby-transformer-sharp": "^5.14.0",
|
43
43
|
"node-fetch": "^3.3.2",
|
44
44
|
"notion-to-md": "^3.1.1",
|
45
|
+
"notion-types": "^7.1.5",
|
45
46
|
"typescript": "^5.7.2"
|
46
47
|
},
|
47
48
|
"devDependencies": {
|