gatsby-source-notion-churnotion 1.1.10 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -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) => {
@@ -70,7 +84,7 @@ const processImageBlock = async (block, actions, getCache, createNodeId, reporte
70
84
  : block.image?.file?.url;
71
85
  if (!imageUrl)
72
86
  return null;
73
- const cacheKey = `${imageUrl}-post-image`;
87
+ const cacheKey = `${block.id}-post-image`;
74
88
  const cachedFileNodeId = await cache.get(cacheKey);
75
89
  if (cachedFileNodeId) {
76
90
  reporter.info(`[CACHE HIT] Image already processed: ${imageUrl}`);
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.12",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",