gatsby-source-notion-churnotion 1.0.20 → 1.0.21

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.
@@ -6,35 +6,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.processBlocks = void 0;
7
7
  const gatsby_source_filesystem_1 = require("gatsby-source-filesystem");
8
8
  const path_1 = __importDefault(require("path"));
9
- const crypto_1 = __importDefault(require("crypto"));
10
9
  const processBlocks = async (blocks, actions, getCache, createNodeId, reporter) => {
11
10
  const { createNode } = actions;
12
11
  let thumbnailUrl = ``;
13
12
  for (const block of blocks) {
14
- // 이미지 블록 처리
13
+ // Process image blocks
15
14
  if (block.type === `image` &&
16
15
  typeof block.parent === `string` &&
17
16
  block.parent.includes(`http`)) {
18
- const match = block.parent.match(/\((https?:\/\/.*\.(?:png|jpg|jpeg|gif|webp))\)/);
17
+ const match = block.parent.match(/\((https?:\/\/.*?)\)/); // Extract URL inside parentheses
19
18
  if (match) {
20
- const imageUrl = match[1]; // 이미지 URL 추출
19
+ const imageUrl = match[1]; // Full image URL
21
20
  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
- // 파일 생성
21
+ // Extract file extension
22
+ const urlWithoutQuery = imageUrl.split("?")[0]; // Remove query parameters
23
+ const fileExtension = path_1.default.extname(urlWithoutQuery); // Extract extension
24
+ // const hashedFileName =
25
+ // crypto.createHash(`md5`).update(imageUrl).digest(`hex`) +
26
+ // fileExtension;
27
+ // Create the file node
27
28
  const fileNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
28
29
  url: imageUrl,
29
- parentNodeId: block.blockId, // 블록 ID 부모로 설정
30
+ parentNodeId: block.blockId, // Set block ID as parent
30
31
  getCache,
31
32
  createNode,
32
33
  createNodeId,
33
- name: hashedFileName,
34
34
  });
35
35
  if (fileNode) {
36
- const relativePath = `/static/images/${hashedFileName}`; // 해싱된 파일명을 사용
37
- block.parent = `![${hashedFileName}](${relativePath})`; // Markdown 형식으로 업데이트
36
+ const relativePath = fileNode.relativePath; // Use hashed file name
37
+ block.parent = block.parent.replace(/\(https?:\/\/.*?\)/, `(${relativePath})`); // Update Markdown syntax
38
38
  if (thumbnailUrl.length === 0)
39
39
  thumbnailUrl = relativePath;
40
40
  reporter.info(`[SUCCESS] Updated block with new hashed image path: ${block.parent}`);
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.21",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",