gatsby-source-notion-churnotion 1.0.23 → 1.0.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -125,7 +125,14 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
125
125
  }
126
126
  const bookId = page.properties?.book?.relation?.[0]?.id || null;
127
127
  const markdownContent = await connector_1.n2m.pageToMarkdown(page.id);
128
- const thumbnailUrl = await (0, imageProcessor_1.processBlocks)(markdownContent, actions, getCache, createNodeId, reporter);
128
+ const imageNode = await (0, imageProcessor_1.processBlocks)(markdownContent, actions, getCache, createNodeId, reporter);
129
+ const gatsbyImageData = {
130
+ childImageSharp: {
131
+ gatsbyImageData: imageNode
132
+ ? `childImageSharp___NODE___${imageNode}`
133
+ : null,
134
+ },
135
+ };
129
136
  const postNode = {
130
137
  id: nodeId,
131
138
  category: parentCategoryId,
@@ -150,7 +157,8 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
150
157
  tags: tagIds,
151
158
  parent: null,
152
159
  url: `${constants_1.COMMON_URI}/${constants_1.POST_URI}${categoryUrl}/${slug}`,
153
- thumbnailUrl: thumbnailUrl,
160
+ thumbnail: imageNode,
161
+ ...gatsbyImageData,
154
162
  };
155
163
  await createNode(postNode);
156
164
  // book과 post 부모-자식 관계 설정
@@ -20,7 +20,7 @@ const createSchemaCustomization = ({ actions }) => {
20
20
  slug: String
21
21
  category_list: [${constants_1.NODE_TYPE.Category}]
22
22
  url: String!
23
- thumbnailUrl: String
23
+ thumbnail: File @link(by: "id", from: "thumbnail")
24
24
  }
25
25
 
26
26
  type ${constants_1.NODE_TYPE.Tag} implements Node {
@@ -1,3 +1,3 @@
1
1
  import { Actions, GatsbyCache, Reporter } from "gatsby";
2
2
  import { MdBlock } from "notion-to-md/build/types";
3
- export declare const processBlocks: (blocks: MdBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter) => Promise<string>;
3
+ export declare const processBlocks: (blocks: MdBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter) => Promise<import("gatsby-source-filesystem").FileSystemNode | null>;
@@ -4,7 +4,7 @@ exports.processBlocks = void 0;
4
4
  const gatsby_source_filesystem_1 = require("gatsby-source-filesystem");
5
5
  const processBlocks = async (blocks, actions, getCache, createNodeId, reporter) => {
6
6
  const { createNode } = actions;
7
- let thumbnailUrl = ``;
7
+ let thumbnail = null;
8
8
  for (const block of blocks) {
9
9
  if (block.type === `image` &&
10
10
  typeof block.parent === `string` &&
@@ -22,9 +22,10 @@ const processBlocks = async (blocks, actions, getCache, createNodeId, reporter)
22
22
  createNodeId,
23
23
  });
24
24
  if (fileNode) {
25
- const publicUrl = fileNode.publicURL;
26
- block.parent = block.parent.replace(/\(https?:\/\/.*?\)/, `(${publicUrl || fileNode.relativePath})`);
27
- reporter.info(`[SUCCESS] Image processed: ${publicUrl}`);
25
+ block.parent = fileNode.id;
26
+ if (!thumbnail)
27
+ thumbnail = fileNode;
28
+ reporter.info(`[SUCCESS] Image processed: ${fileNode.id}`);
28
29
  }
29
30
  }
30
31
  catch (error) {
@@ -33,6 +34,6 @@ const processBlocks = async (blocks, actions, getCache, createNodeId, reporter)
33
34
  }
34
35
  }
35
36
  }
36
- return thumbnailUrl;
37
+ return thumbnail;
37
38
  };
38
39
  exports.processBlocks = processBlocks;
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.23",
4
+ "version": "1.0.25",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",