gatsby-source-notion-churnotion 1.0.64 → 1.0.65

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.
@@ -139,14 +139,14 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
139
139
  });
140
140
  }
141
141
  const bookId = page.properties?.book?.relation?.[0]?.id || null;
142
- const [imageNode, tableOfContents] = await (0, processor_1.processor)(pageData.results, actions, getCache, createNodeId, reporter);
142
+ const [imageNode, tableOfContents, updatedBlocks] = await (0, processor_1.processor)(pageData.results, actions, getCache, createNodeId, reporter);
143
143
  const postNode = {
144
144
  id: nodeId,
145
145
  category: parentCategoryId,
146
146
  book: getNode(`${bookId}-book`),
147
147
  book_index: page.properties?.bookIndex?.number || 0,
148
148
  title: title,
149
- content: pageData.results,
149
+ content: updatedBlocks,
150
150
  create_date: page.created_time,
151
151
  update_date: page.last_edited_time,
152
152
  version: page.properties?.version?.number || null,
@@ -1,7 +1,7 @@
1
1
  import { Actions, GatsbyCache, Reporter } from "gatsby";
2
2
  import { BaseContentBlock } from "notion-types";
3
- export declare const processor: (blocks: BaseContentBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter) => Promise<(string | {
3
+ export declare const processor: (blocks: BaseContentBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter) => Promise<[string | null, {
4
4
  type: string;
5
5
  hash: string;
6
6
  title: string;
7
- }[] | null)[]>;
7
+ }[], BaseContentBlock[]]>;
@@ -5,22 +5,22 @@ const gatsby_source_filesystem_1 = require("gatsby-source-filesystem");
5
5
  const metadataProcessor_1 = require("./metadataProcessor");
6
6
  const tableOfContent_1 = require("./tableOfContent");
7
7
  const processor = async (blocks, actions, getCache, createNodeId, reporter) => {
8
- const { thumbnail, tableOfContents } = await processBlocksForContent(blocks, actions, getCache, createNodeId, reporter);
8
+ const { thumbnail, tableOfContents, updatedBlocks } = await processBlocksForContent(blocks, actions, getCache, createNodeId, reporter);
9
9
  await (0, metadataProcessor_1.processMetadata)(blocks, actions, createNodeId, reporter);
10
- return [thumbnail, tableOfContents];
10
+ return [thumbnail, tableOfContents, updatedBlocks];
11
11
  };
12
12
  exports.processor = processor;
13
13
  const processBlocksForContent = async (blocks, actions, getCache, createNodeId, reporter) => {
14
- const { createNode } = actions;
15
14
  const tableOfContents = [];
16
15
  let thumbnail = null;
17
- for (const block of blocks) {
16
+ const updatedBlocks = (await Promise.all(blocks.map(async (block) => {
18
17
  await (0, tableOfContent_1.processTableOfContents)(block, tableOfContents);
19
18
  if (isImageBlock(block)) {
20
- thumbnail ||= await processImageBlock(block, actions, getCache, createNodeId, reporter);
19
+ return await processImageBlock(block, actions, getCache, createNodeId, reporter);
21
20
  }
22
- }
23
- return { thumbnail, tableOfContents };
21
+ return block;
22
+ }))).filter((block) => block !== null);
23
+ return { thumbnail, tableOfContents, updatedBlocks };
24
24
  };
25
25
  const isImageBlock = (block) => {
26
26
  return block.type === "image" && "image" in block;
@@ -43,12 +43,15 @@ const processImageBlock = async (block, actions, getCache, createNodeId, reporte
43
43
  createNodeId,
44
44
  });
45
45
  if (fileNode) {
46
- block.image = {
47
- fileId: fileNode.id,
48
- caption: block.image.caption,
46
+ const updatedBlock = {
47
+ ...block,
48
+ image: {
49
+ fileId: fileNode.id,
50
+ caption: block.image.caption,
51
+ },
49
52
  };
50
53
  reporter.info(`[SUCCESS] Image processed: ${fileNode.id}`);
51
- return fileNode.id;
54
+ return updatedBlock;
52
55
  }
53
56
  }
54
57
  catch (error) {
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.64",
4
+ "version": "1.0.65",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",