gatsby-source-notion-churnotion 1.0.75 → 1.0.77
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,2 +1,2 @@
|
|
1
|
-
import { Actions, Reporter } from "gatsby";
|
2
|
-
export declare const processMetadata: (blocks: any[], actions: Actions, createNodeId: (input: string) => string, reporter: Reporter) => Promise<any[]>;
|
1
|
+
import { Actions, GatsbyCache, Reporter } from "gatsby";
|
2
|
+
export declare const processMetadata: (blocks: any[], actions: Actions, createNodeId: (input: string) => string, reporter: Reporter, cache: GatsbyCache) => Promise<any[]>;
|
@@ -17,7 +17,7 @@ const scraper = (0, metascraper_1.default)([
|
|
17
17
|
(0, metascraper_description_1.default)(),
|
18
18
|
(0, metascraper_image_1.default)(),
|
19
19
|
]);
|
20
|
-
const processMetadata = async (blocks, actions, createNodeId, reporter) => {
|
20
|
+
const processMetadata = async (blocks, actions, createNodeId, reporter, cache) => {
|
21
21
|
const { createNode } = actions;
|
22
22
|
for (const block of blocks) {
|
23
23
|
if (block.type === "text" ||
|
@@ -31,6 +31,17 @@ const processMetadata = async (blocks, actions, createNodeId, reporter) => {
|
|
31
31
|
const href = text.href;
|
32
32
|
if (href) {
|
33
33
|
try {
|
34
|
+
reporter.info(`[INFO] Processing metadata for URL: ${href}`);
|
35
|
+
const cacheKey = `metadata-${crypto_1.default
|
36
|
+
.createHash("md5")
|
37
|
+
.update(href)
|
38
|
+
.digest("hex")}`;
|
39
|
+
const cachedMetadata = await cache.get(cacheKey);
|
40
|
+
if (cachedMetadata) {
|
41
|
+
reporter.info(`[INFO] Using cached metadata for URL: ${href}`);
|
42
|
+
text.href = cachedMetadata.nodeId;
|
43
|
+
continue;
|
44
|
+
}
|
34
45
|
reporter.info(`[INFO] Fetching metadata for URL: ${href}`);
|
35
46
|
const response = await fetch(href, {
|
36
47
|
headers: { "User-Agent": "Mozilla/5.0" },
|
@@ -56,6 +67,7 @@ const processMetadata = async (blocks, actions, createNodeId, reporter) => {
|
|
56
67
|
};
|
57
68
|
createNode(metadataNode);
|
58
69
|
reporter.info(`[SUCCESS] Created metadata node for URL: ${href}`);
|
70
|
+
await cache.set(cacheKey, { ...metadata, nodeId });
|
59
71
|
text.href = nodeId;
|
60
72
|
}
|
61
73
|
catch (error) {
|
package/dist/util/processor.js
CHANGED
@@ -6,7 +6,7 @@ const metadataProcessor_1 = require("./metadataProcessor");
|
|
6
6
|
const tableOfContent_1 = require("./tableOfContent");
|
7
7
|
const processor = async (blocks, actions, getCache, createNodeId, reporter, cache) => {
|
8
8
|
const { thumbnail, tableOfContents, updatedBlocks, rawText } = await processBlocksForContent(blocks, actions, getCache, createNodeId, reporter, cache);
|
9
|
-
await (0, metadataProcessor_1.processMetadata)(blocks, actions, createNodeId, reporter);
|
9
|
+
await (0, metadataProcessor_1.processMetadata)(blocks, actions, createNodeId, reporter, cache);
|
10
10
|
return [thumbnail, tableOfContents, updatedBlocks, rawText];
|
11
11
|
};
|
12
12
|
exports.processor = processor;
|
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.77",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|