gatsby-source-notion-churnotion 1.0.21 → 1.0.23
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/util/imageProcessor.js +7 -20
- package/package.json +3 -1
@@ -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
5
|
const processBlocks = async (blocks, actions, getCache, createNodeId, reporter) => {
|
10
6
|
const { createNode } = actions;
|
11
7
|
let thumbnailUrl = ``;
|
12
8
|
for (const block of blocks) {
|
13
|
-
// Process image blocks
|
14
9
|
if (block.type === `image` &&
|
15
10
|
typeof block.parent === `string` &&
|
16
11
|
block.parent.includes(`http`)) {
|
17
|
-
const match = block.parent.match(/\((https?:\/\/.*?)\)/);
|
12
|
+
const match = block.parent.match(/\((https?:\/\/.*?)\)/);
|
18
13
|
if (match) {
|
19
|
-
const imageUrl = match[1];
|
14
|
+
const imageUrl = match[1];
|
15
|
+
reporter.info(`[Image] got image > ${imageUrl}`);
|
20
16
|
try {
|
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
|
28
17
|
const fileNode = await (0, gatsby_source_filesystem_1.createRemoteFileNode)({
|
29
18
|
url: imageUrl,
|
30
|
-
parentNodeId: block.blockId,
|
19
|
+
parentNodeId: block.blockId,
|
31
20
|
getCache,
|
32
21
|
createNode,
|
33
22
|
createNodeId,
|
34
23
|
});
|
35
24
|
if (fileNode) {
|
36
|
-
const
|
37
|
-
block.parent = block.parent.replace(/\(https?:\/\/.*?\)/, `(${relativePath})`);
|
38
|
-
|
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.
|
4
|
+
"version": "1.0.23",
|
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"
|