gatsby-source-notion-churnotion 1.0.47 → 1.0.49

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.
@@ -10,29 +10,35 @@ const processBlocks = async (blocks, actions, getCache, createNodeId, reporter)
10
10
  const { createNode } = actions;
11
11
  let thumbnail = null;
12
12
  for (const block of blocks) {
13
- if (isImageBlock(block) && block?.image?.file?.url) {
14
- const match = block.image.file.url.match(/\((https?:\/\/.*?)\)/);
15
- if (match) {
16
- const imageUrl = match[1];
17
- reporter.info(`[Image] got image > ${imageUrl}`);
18
- try {
19
- const fileNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
20
- url: imageUrl,
21
- parentNodeId: block.id,
22
- getCache,
23
- createNode,
24
- createNodeId,
25
- });
26
- if (fileNode) {
27
- if (!thumbnail)
28
- thumbnail = fileNode.id;
29
- reporter.info(`[SUCCESS] Image processed: ${fileNode.id}`);
30
- }
31
- }
32
- catch (error) {
33
- reporter.warn(`[WARNING] Failed to download image: ${imageUrl}`);
13
+ if (isImageBlock(block)) {
14
+ const imageSourceType = block.image.type;
15
+ const imageUrl = imageSourceType === `external`
16
+ ? block.image.external?.url
17
+ : block.image?.file?.url;
18
+ if (!imageUrl)
19
+ continue;
20
+ reporter.info(`[Image] got image > ${imageUrl}`);
21
+ try {
22
+ const fileNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
23
+ url: imageUrl,
24
+ parentNodeId: block.id,
25
+ getCache,
26
+ createNode,
27
+ createNodeId,
28
+ });
29
+ if (fileNode) {
30
+ block.image = {
31
+ id: fileNode.id,
32
+ caption: block.image.caption,
33
+ };
34
+ if (!thumbnail)
35
+ thumbnail = fileNode.id;
36
+ reporter.info(`[SUCCESS] Image processed: ${fileNode.id}`);
34
37
  }
35
38
  }
39
+ catch (error) {
40
+ reporter.warn(`[WARNING] Failed to download image: ${imageUrl}`);
41
+ }
36
42
  }
37
43
  }
38
44
  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.47",
4
+ "version": "1.0.49",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",