gatsby-source-notion-churnotion 1.0.20 → 1.0.22

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.
@@ -1,43 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.processBlocks = void 0;
7
4
  const gatsby_source_filesystem_1 = require("gatsby-source-filesystem");
8
- const path_1 = __importDefault(require("path"));
9
- const crypto_1 = __importDefault(require("crypto"));
10
5
  const processBlocks = async (blocks, actions, getCache, createNodeId, reporter) => {
11
6
  const { createNode } = actions;
12
7
  let thumbnailUrl = ``;
13
8
  for (const block of blocks) {
14
- // 이미지 블록 처리
15
9
  if (block.type === `image` &&
16
10
  typeof block.parent === `string` &&
17
11
  block.parent.includes(`http`)) {
18
- const match = block.parent.match(/\((https?:\/\/.*\.(?:png|jpg|jpeg|gif|webp))\)/);
12
+ const match = block.parent.match(/\((https?:\/\/.*?)\)/);
19
13
  if (match) {
20
- const imageUrl = match[1]; // 이미지 URL 추출
14
+ const imageUrl = match[1].slice(1, match[1].length - 1);
15
+ reporter.info(`[Image] got image > ${imageUrl}`);
21
16
  try {
22
- // 해싱된 파일명 생성
23
- const fileExtension = path_1.default.extname(imageUrl); // 확장자 추출
24
- const hashedFileName = crypto_1.default.createHash(`md5`).update(imageUrl).digest(`hex`) +
25
- fileExtension;
26
- // 파일 생성
27
17
  const fileNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
28
18
  url: imageUrl,
29
- parentNodeId: block.blockId, // 블록 ID를 부모로 설정
19
+ parentNodeId: block.blockId,
30
20
  getCache,
31
21
  createNode,
32
22
  createNodeId,
33
- name: hashedFileName,
34
23
  });
35
24
  if (fileNode) {
36
- const relativePath = `/static/images/${hashedFileName}`; // 해싱된 파일명을 사용
37
- block.parent = `![${hashedFileName}](${relativePath})`; // Markdown 형식으로 업데이트
38
- if (thumbnailUrl.length === 0)
39
- thumbnailUrl = relativePath;
40
- reporter.info(`[SUCCESS] Updated block with new hashed image path: ${block.parent}`);
25
+ const publicUrl = fileNode.publicURL;
26
+ block.parent = block.parent.replace(/\(https?:\/\/.*?\)/, `(${publicUrl || fileNode.relativePath})`);
27
+ reporter.info(`[SUCCESS] Image processed: ${publicUrl}`);
41
28
  }
42
29
  }
43
30
  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.20",
4
+ "version": "1.0.22",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",
@@ -38,6 +38,8 @@
38
38
  "axios": "^1.7.9",
39
39
  "gatsby-source-filesystem": "^5.14.0",
40
40
  "gatsby-transformer-json": "^5.14.0",
41
+ "gatsby-transformer-sharp": "^5.14.0",
42
+ "gatsby-plugin-sharp": "^5.14.0",
41
43
  "node-fetch": "^3.3.2",
42
44
  "notion-to-md": "^3.1.1",
43
45
  "typescript": "^5.7.2"