gatsby-source-notion-churnotion 1.0.50 → 1.0.51
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.
package/dist/api/getPages.js
CHANGED
@@ -9,6 +9,7 @@ const constants_1 = require("../constants");
|
|
9
9
|
const fetchData_1 = require("../util/fetchData");
|
10
10
|
const imageProcessor_1 = require("../util/imageProcessor");
|
11
11
|
const slugify_1 = require("../util/slugify");
|
12
|
+
const tableOfContent_1 = require("../util/tableOfContent");
|
12
13
|
const getPages = async ({ databaseId, reporter, getCache, actions, createNode, createNodeId, createParentChildLink, getNode, }) => {
|
13
14
|
/**
|
14
15
|
* 데이터베이스 내에 페이지들을 읽어서 재귀적으로 추가하는 서브 메서드드
|
@@ -26,7 +27,6 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
26
27
|
reporter.info(`[SUCCESS] total pages > ${result.results.length}`);
|
27
28
|
}
|
28
29
|
for (const page of result.results) {
|
29
|
-
reporter.info(`[CHECK] page: ${page.id}`);
|
30
30
|
const pageUrl = `blocks/${page.id}/children?page_size=100`;
|
31
31
|
// 페이지 데이터
|
32
32
|
const pageData = await (0, fetchData_1.fetchGetWithRetry)(pageUrl);
|
@@ -141,6 +141,7 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
141
141
|
}
|
142
142
|
const bookId = page.properties?.book?.relation?.[0]?.id || null;
|
143
143
|
const imageNode = await (0, imageProcessor_1.processBlocks)(pageData.results, actions, getCache, createNodeId, reporter);
|
144
|
+
const tableOfContents = await (0, tableOfContent_1.processTableOfContents)(pageData.results, actions, getCache, createNodeId, reporter);
|
144
145
|
const postNode = {
|
145
146
|
id: nodeId,
|
146
147
|
category: parentCategoryId,
|
@@ -155,6 +156,7 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
|
|
155
156
|
slug: slug,
|
156
157
|
category_list: categoryPath,
|
157
158
|
children: [],
|
159
|
+
tableOfContents,
|
158
160
|
internal: {
|
159
161
|
type: constants_1.NODE_TYPE.Post,
|
160
162
|
contentDigest: crypto_1.default
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Actions, GatsbyCache, Reporter } from "gatsby";
|
2
|
+
import { BaseContentBlock } from "notion-types";
|
3
|
+
export declare const processTableOfContents: (blocks: BaseContentBlock[], actions: Actions, getCache: (this: void, id: string) => GatsbyCache, createNodeId: (this: void, input: string) => string, reporter: Reporter) => Promise<{
|
4
|
+
type: string;
|
5
|
+
hash: string;
|
6
|
+
title: string;
|
7
|
+
}[]>;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.processTableOfContents = void 0;
|
4
|
+
const isHeading = (block) => {
|
5
|
+
return ["heading_1", "heading_2", "heading_3"].includes(block.type);
|
6
|
+
};
|
7
|
+
const processTableOfContents = async (blocks, actions, getCache, createNodeId, reporter) => {
|
8
|
+
const tableOfContents = [];
|
9
|
+
for (const block of blocks) {
|
10
|
+
if (isHeading(block) &&
|
11
|
+
(block.type === "heading_1" ||
|
12
|
+
block.type === "heading_2" ||
|
13
|
+
block.type === "heading_3")) {
|
14
|
+
const plainText = block[block.type]?.rich_text[0]?.plain_text || "";
|
15
|
+
const hash = `#${plainText.replace(/\s+/g, "-").toLowerCase()}`;
|
16
|
+
block.hash = hash;
|
17
|
+
tableOfContents.push({
|
18
|
+
type: block.type,
|
19
|
+
hash,
|
20
|
+
title: plainText,
|
21
|
+
});
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return tableOfContents;
|
25
|
+
};
|
26
|
+
exports.processTableOfContents = processTableOfContents;
|
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.51",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|