gatsby-source-notion-churnotion 1.1.10 → 1.1.11

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.
@@ -15,7 +15,24 @@ const processBlocksForContent = async (blocks, actions, getCache, createNodeId,
15
15
  let thumbnail = null;
16
16
  let rawText = "";
17
17
  const updatedBlocks = [];
18
+ let firstImageBlock = null;
18
19
  for (const block of blocks) {
20
+ if (isImageBlock(block)) {
21
+ firstImageBlock = block;
22
+ break;
23
+ }
24
+ }
25
+ if (firstImageBlock) {
26
+ const updatedBlock = await processImageBlock(firstImageBlock, actions, getCache, createNodeId, reporter, cache);
27
+ if (updatedBlock?.image?.fileId) {
28
+ thumbnail = updatedBlock.image.fileId;
29
+ }
30
+ updatedBlocks[blocks.indexOf(firstImageBlock)] =
31
+ updatedBlock || firstImageBlock;
32
+ }
33
+ await Promise.all(blocks.map(async (block, index) => {
34
+ if (block === firstImageBlock)
35
+ return;
19
36
  await (0, tableOfContent_1.processTableOfContents)(block, tableOfContents);
20
37
  const plainText = extractPlainText(block);
21
38
  if (plainText) {
@@ -23,15 +40,12 @@ const processBlocksForContent = async (blocks, actions, getCache, createNodeId,
23
40
  }
24
41
  if (isImageBlock(block)) {
25
42
  const updatedBlock = await processImageBlock(block, actions, getCache, createNodeId, reporter, cache);
26
- if (!thumbnail && updatedBlock?.image?.fileId) {
27
- thumbnail = updatedBlock.image.fileId;
28
- }
29
- updatedBlocks.push(updatedBlock || block);
43
+ updatedBlocks[index] = updatedBlock || block;
30
44
  }
31
45
  else {
32
- updatedBlocks.push(block);
46
+ updatedBlocks[index] = block;
33
47
  }
34
- }
48
+ }));
35
49
  return { thumbnail, tableOfContents, updatedBlocks, rawText };
36
50
  };
37
51
  const isTextContentBlock = (block) => {
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.10",
4
+ "version": "1.1.11",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",