gatsby-source-notion-churnotion 1.1.18 → 1.1.20
Sign up to get free protection for your applications and to get access to all the features.
@@ -60,7 +60,7 @@ const processMetadata = async (blocks, actions, createNodeId, reporter, cache) =
|
|
60
60
|
title: metadata.title || "",
|
61
61
|
description: metadata.description || "",
|
62
62
|
image: metadata.image || "",
|
63
|
-
url:
|
63
|
+
url: href,
|
64
64
|
};
|
65
65
|
createNode(metadataNode);
|
66
66
|
reporter.info(`[SUCCESS] Created metadata node for URL: ${href}`);
|
package/dist/util/processor.js
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.processor = void 0;
|
4
7
|
const gatsby_source_filesystem_1 = require("gatsby-source-filesystem");
|
5
8
|
const metadataProcessor_1 = require("./metadataProcessor");
|
6
9
|
const tableOfContent_1 = require("./tableOfContent");
|
10
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
11
|
+
const path_1 = __importDefault(require("path"));
|
12
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
7
13
|
const processor = async (blocks, actions, getCache, createNodeId, reporter, cache) => {
|
8
14
|
const { thumbnail, tableOfContents, updatedBlocks, rawText } = await processBlocksForContent(blocks, actions, getCache, createNodeId, reporter, cache);
|
9
15
|
await (0, metadataProcessor_1.processMetadata)(blocks, actions, createNodeId, reporter, cache);
|
@@ -84,6 +90,43 @@ const processImageBlock = async (block, actions, getCache, createNodeId, reporte
|
|
84
90
|
: block.image?.file?.url;
|
85
91
|
if (!imageUrl)
|
86
92
|
return null;
|
93
|
+
// GIF 파일 처리
|
94
|
+
if (imageUrl.endsWith(".gif")) {
|
95
|
+
const staticDir = path_1.default.join(process.cwd(), "static"); // Gatsby의 static 디렉토리
|
96
|
+
const gifFileName = path_1.default.basename(imageUrl); // 파일 이름 추출
|
97
|
+
const gifFilePath = path_1.default.join(staticDir, gifFileName);
|
98
|
+
// 이미 static 디렉토리에 파일이 있는지 확인
|
99
|
+
if (!fs_extra_1.default.existsSync(gifFilePath)) {
|
100
|
+
try {
|
101
|
+
reporter.info(`[GIF PROCESSING] Downloading GIF: ${imageUrl}`);
|
102
|
+
const response = await (0, node_fetch_1.default)(imageUrl);
|
103
|
+
if (!response.ok) {
|
104
|
+
throw new Error(`Failed to download GIF: ${response.statusText}`);
|
105
|
+
}
|
106
|
+
const buffer = await response.buffer();
|
107
|
+
await fs_extra_1.default.ensureDir(staticDir); // static 디렉토리 생성
|
108
|
+
await fs_extra_1.default.writeFile(gifFilePath, buffer); // GIF 파일 저장
|
109
|
+
reporter.info(`[GIF SUCCESS] Saved GIF to static: ${gifFilePath}`);
|
110
|
+
}
|
111
|
+
catch (error) {
|
112
|
+
reporter.warn(`[GIF WARNING] Failed to process GIF: ${imageUrl}`);
|
113
|
+
return null;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
reporter.info(`[GIF CACHE HIT] GIF already exists: ${gifFilePath}`);
|
118
|
+
}
|
119
|
+
// GIF 파일을 정적 파일로 추가
|
120
|
+
const updatedBlock = {
|
121
|
+
...block,
|
122
|
+
image: {
|
123
|
+
fileId: gifFileName, // static 경로를 기준으로 참조
|
124
|
+
caption: block.image.caption,
|
125
|
+
},
|
126
|
+
};
|
127
|
+
return updatedBlock;
|
128
|
+
}
|
129
|
+
// GIF가 아닌 경우 기존 로직 유지
|
87
130
|
const cacheKey = `${imageUrl}-post-image`;
|
88
131
|
const cachedFileNodeId = await cache.get(cacheKey);
|
89
132
|
if (cachedFileNodeId) {
|
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.
|
4
|
+
"version": "1.1.20",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|
@@ -34,9 +34,11 @@
|
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
36
|
"@notionhq/client": "^2.2.15",
|
37
|
+
"@types/fs-extra": "^11.0.4",
|
37
38
|
"@types/node": "^22.10.2",
|
38
39
|
"axios": "^1.7.9",
|
39
40
|
"compute-cosine-similarity": "^1.1.0",
|
41
|
+
"fs-extra": "^11.3.0",
|
40
42
|
"gatsby-plugin-sharp": "^5.14.0",
|
41
43
|
"gatsby-source-filesystem": "^5.14.0",
|
42
44
|
"gatsby-transformer-json": "^5.14.0",
|
@@ -53,6 +55,7 @@
|
|
53
55
|
"typescript": "^5.7.2"
|
54
56
|
},
|
55
57
|
"devDependencies": {
|
58
|
+
"@types/node-fetch": "^2.6.12",
|
56
59
|
"gatsby": "^5.14.0"
|
57
60
|
},
|
58
61
|
"peerDependencies": {
|