gatsby-source-notion-churnotion 1.1.9 → 1.1.11

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