gatsby-source-notion-churnotion 1.1.19 → 1.1.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/util/processor.js +43 -0
- package/package.json +4 -2
package/dist/util/processor.js
CHANGED
@@ -1,9 +1,14 @@
|
|
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"));
|
7
12
|
const processor = async (blocks, actions, getCache, createNodeId, reporter, cache) => {
|
8
13
|
const { thumbnail, tableOfContents, updatedBlocks, rawText } = await processBlocksForContent(blocks, actions, getCache, createNodeId, reporter, cache);
|
9
14
|
await (0, metadataProcessor_1.processMetadata)(blocks, actions, createNodeId, reporter, cache);
|
@@ -84,6 +89,44 @@ const processImageBlock = async (block, actions, getCache, createNodeId, reporte
|
|
84
89
|
: block.image?.file?.url;
|
85
90
|
if (!imageUrl)
|
86
91
|
return null;
|
92
|
+
// GIF 파일 처리
|
93
|
+
if (imageUrl.endsWith(".gif")) {
|
94
|
+
const staticDir = path_1.default.join(process.cwd(), "static"); // Gatsby의 static 디렉토리
|
95
|
+
const gifFileName = path_1.default.basename(imageUrl); // 파일 이름 추출
|
96
|
+
const gifFilePath = path_1.default.join(staticDir, gifFileName);
|
97
|
+
// 이미 static 디렉토리에 파일이 있는지 확인
|
98
|
+
if (!fs_extra_1.default.existsSync(gifFilePath)) {
|
99
|
+
try {
|
100
|
+
reporter.info(`[GIF PROCESSING] Downloading GIF: ${imageUrl}`);
|
101
|
+
const response = await fetch(imageUrl);
|
102
|
+
if (!response.ok) {
|
103
|
+
throw new Error(`Failed to download GIF: ${response.statusText}`);
|
104
|
+
}
|
105
|
+
const arrayBuffer = await response.arrayBuffer();
|
106
|
+
const buffer = Buffer.from(arrayBuffer);
|
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.21",
|
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",
|
@@ -47,12 +49,12 @@
|
|
47
49
|
"metascraper-title": "^5.45.25",
|
48
50
|
"metascraper-url": "^5.45.25",
|
49
51
|
"natural": "^8.0.1",
|
50
|
-
"node-fetch": "^3.3.2",
|
51
52
|
"notion-to-md": "^3.1.1",
|
52
53
|
"notion-types": "^7.1.5",
|
53
54
|
"typescript": "^5.7.2"
|
54
55
|
},
|
55
56
|
"devDependencies": {
|
57
|
+
"@types/node-fetch": "^2.6.12",
|
56
58
|
"gatsby": "^5.14.0"
|
57
59
|
},
|
58
60
|
"peerDependencies": {
|