gatsby-source-notion-churnotion 1.2.8 → 1.2.9
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/util/resolvers.js +48 -3
- package/dist/util/tableOfContent.js +55 -46
- package/dist/util/tocHelper.d.ts +1 -1
- package/dist/util/tocHelper.js +63 -139
- package/package.json +1 -1
package/dist/util/resolvers.js
CHANGED
@@ -106,17 +106,31 @@ const formatTableOfContents = (tableOfContents, reporter) => {
|
|
106
106
|
entry.title.includes("프록시")));
|
107
107
|
// Process special handling for server sections
|
108
108
|
for (const serverSection of serverSections) {
|
109
|
+
// 스퀴드 프록시 서버 섹션인지 특별히 확인
|
110
|
+
const isSquidProxySection = serverSection.title.includes("Squid") ||
|
111
|
+
serverSection.title.includes("프록시") ||
|
112
|
+
serverSection.title.includes("Proxy");
|
109
113
|
// Get direct children of this server section
|
110
114
|
const directChildren = childrenByParent.get(serverSection.hash) || new Set();
|
111
115
|
// Check each child for common command pattern matching
|
112
116
|
for (const childHash of directChildren) {
|
113
117
|
const child = headingsByHash.get(childHash);
|
114
118
|
if (child && commonCommandPattern.test(child.title)) {
|
115
|
-
//
|
119
|
+
// 스퀴드 프록시 섹션의 명령어는 무조건 제거 (컨텐츠 유무와 상관없이)
|
120
|
+
if (isSquidProxySection) {
|
121
|
+
invalidEntries.add(childHash);
|
122
|
+
// Also, mark children as invalid if there are any
|
123
|
+
if (childrenByParent.has(childHash)) {
|
124
|
+
for (const grandChildHash of childrenByParent.get(childHash)) {
|
125
|
+
invalidEntries.add(grandChildHash);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
continue;
|
129
|
+
}
|
130
|
+
// 다른 서버 섹션은 기존 로직대로 처리
|
116
131
|
const childHasChildren = childrenByParent.has(childHash) &&
|
117
132
|
childrenByParent.get(childHash).size > 0;
|
118
|
-
// Special check for service section headings
|
119
|
-
// if they don't have meaningful content
|
133
|
+
// Special check for service section headings
|
120
134
|
if (!childHasChildren) {
|
121
135
|
invalidEntries.add(childHash);
|
122
136
|
// Also, mark children as invalid if there are any
|
@@ -145,6 +159,37 @@ const formatTableOfContents = (tableOfContents, reporter) => {
|
|
145
159
|
}
|
146
160
|
}
|
147
161
|
}
|
162
|
+
// 최종 필터링 - 강제 제거 대상
|
163
|
+
const forceRemoveMap = new Map(); // 부모 해시 -> 제거할 자식 해시 세트
|
164
|
+
// 스퀴드 프록시 서버 섹션 찾기
|
165
|
+
const squidSection = sortedToc.find((entry) => entry.level === 1 &&
|
166
|
+
(entry.title.includes("Squid") ||
|
167
|
+
entry.title.includes("프록시") ||
|
168
|
+
entry.title.includes("Proxy")));
|
169
|
+
if (squidSection) {
|
170
|
+
// 스퀴드 섹션 내 명령어 찾기
|
171
|
+
const squidChildEntries = sortedToc.filter((entry) => entry.level === 2 && entry.parentHash === squidSection.hash);
|
172
|
+
// 일반 명령어 패턴
|
173
|
+
const finalCommandPattern = /^(cp|mv|rm|find|locate|grep|curl|wget|ls|chmod|chown|ps|sed|awk|cat|service|file|stat)$/i;
|
174
|
+
// 스퀴드 섹션 내 명령어 중 일반 명령어인 경우
|
175
|
+
for (const child of squidChildEntries) {
|
176
|
+
if (finalCommandPattern.test(child.title)) {
|
177
|
+
// 제거 대상 목록에 추가
|
178
|
+
if (!forceRemoveMap.has(squidSection.hash)) {
|
179
|
+
forceRemoveMap.set(squidSection.hash, new Set());
|
180
|
+
}
|
181
|
+
forceRemoveMap.get(squidSection.hash).add(child.hash);
|
182
|
+
// 해당 명령어의 자식들도 제거 대상에 추가
|
183
|
+
const childChildren = sortedToc.filter((entry) => entry.parentHash === child.hash);
|
184
|
+
for (const grandChild of childChildren) {
|
185
|
+
invalidEntries.add(grandChild.hash);
|
186
|
+
}
|
187
|
+
// 명령어 자체도 제거 대상에 추가
|
188
|
+
invalidEntries.add(child.hash);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
reporter.info(`Forcibly removed ${invalidEntries.size} entries from Squid Proxy section`);
|
192
|
+
}
|
148
193
|
// Create a filtered TOC without invalid entries
|
149
194
|
const validToc = sortedToc.filter((entry) => !invalidEntries.has(entry.hash));
|
150
195
|
if (invalidEntries.size > 0) {
|
@@ -2,27 +2,13 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.processTableOfContents = exports.resetTocContext = void 0;
|
4
4
|
const crypto_1 = require("crypto");
|
5
|
-
// Hash
|
5
|
+
// Hash cache for generation
|
6
6
|
const hashCache = new Map();
|
7
|
-
//
|
8
|
-
|
9
|
-
let
|
10
|
-
|
11
|
-
|
12
|
-
lastHeadingByLevel = [null, null, null, null];
|
13
|
-
hashCache.clear();
|
14
|
-
};
|
15
|
-
exports.resetTocContext = resetTocContext;
|
16
|
-
// 필요한 수준의 상위 헤딩 찾기
|
17
|
-
const findParentHeading = (currentLevel) => {
|
18
|
-
// 자신보다 낮은 레벨의 가장 가까운 헤딩 찾기 (1 < 2 < 3)
|
19
|
-
for (let level = currentLevel - 1; level > 0; level--) {
|
20
|
-
if (lastHeadingByLevel[level]) {
|
21
|
-
return lastHeadingByLevel[level];
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return null;
|
25
|
-
};
|
7
|
+
// Track current context by level
|
8
|
+
let currentH1 = null;
|
9
|
+
let currentH2 = null;
|
10
|
+
let currentH3 = null;
|
11
|
+
// Generate a hash for a heading
|
26
12
|
const generateHash = (text) => {
|
27
13
|
return `link-${text
|
28
14
|
.replace(/[^a-zA-Z0-9가-힣\s-_]/g, "")
|
@@ -30,15 +16,22 @@ const generateHash = (text) => {
|
|
30
16
|
.replace(/\s+/g, "-")
|
31
17
|
.toLowerCase()}-${(0, crypto_1.randomUUID)().substring(0, 4)}`;
|
32
18
|
};
|
19
|
+
// Reset context between pages/documents
|
20
|
+
const resetTocContext = () => {
|
21
|
+
currentH1 = null;
|
22
|
+
currentH2 = null;
|
23
|
+
currentH3 = null;
|
24
|
+
hashCache.clear();
|
25
|
+
};
|
26
|
+
exports.resetTocContext = resetTocContext;
|
33
27
|
const processTableOfContents = async (block, tableOfContents) => {
|
34
28
|
if (["heading_1", "heading_2", "heading_3"].includes(block.type) &&
|
35
29
|
block[block.type]?.rich_text?.length > 0) {
|
36
30
|
const plainText = block[block.type]?.rich_text?.[0]?.plain_text || "";
|
37
|
-
//
|
31
|
+
// Extract heading level (1, 2, or 3)
|
38
32
|
const level = parseInt(block.type.split("_")[1]);
|
39
|
-
//
|
33
|
+
// Generate or retrieve hash from cache
|
40
34
|
const contextualId = `h${level}-${plainText}`;
|
41
|
-
// 해시 생성 또는 캐시에서 가져오기
|
42
35
|
let hash;
|
43
36
|
if (hashCache.has(contextualId)) {
|
44
37
|
hash = hashCache.get(contextualId);
|
@@ -47,37 +40,53 @@ const processTableOfContents = async (block, tableOfContents) => {
|
|
47
40
|
hash = generateHash(plainText);
|
48
41
|
hashCache.set(contextualId, hash);
|
49
42
|
}
|
43
|
+
// Set hash on block for reference
|
50
44
|
block.hash = hash;
|
51
|
-
//
|
52
|
-
|
53
|
-
for (let i = level + 1; i < lastHeadingByLevel.length; i++) {
|
54
|
-
lastHeadingByLevel[i] = null;
|
55
|
-
}
|
56
|
-
// 부모 헤딩 찾기
|
57
|
-
const parentHeading = findParentHeading(level);
|
58
|
-
const parentHash = parentHeading ? parentHeading.hash : "";
|
59
|
-
// 부모 헤딩 스택에 자식으로 등록
|
60
|
-
if (parentHeading) {
|
61
|
-
parentHeading.children.push(hash);
|
62
|
-
}
|
63
|
-
// 컨텍스트 제목 생성
|
64
|
-
let contextTitle = plainText;
|
65
|
-
// 부모 컨텍스트 추가
|
66
|
-
if (level > 1 && parentHeading) {
|
67
|
-
contextTitle = `${plainText} (${parentHeading.title})`;
|
68
|
-
}
|
69
|
-
// 자신을 현재 레벨의 마지막 헤딩으로 등록
|
70
|
-
const currentHeading = {
|
45
|
+
// Create new heading context
|
46
|
+
const newHeading = {
|
71
47
|
hash,
|
72
48
|
title: plainText,
|
73
49
|
level,
|
74
50
|
children: [],
|
75
51
|
};
|
76
|
-
|
77
|
-
|
52
|
+
// Manage hierarchy based on heading level
|
53
|
+
let parentHash = "";
|
54
|
+
let contextTitle = plainText;
|
55
|
+
if (level === 1) {
|
56
|
+
// New H1 starts a completely new context
|
57
|
+
currentH1 = newHeading;
|
58
|
+
currentH2 = null;
|
59
|
+
currentH3 = null;
|
60
|
+
parentHash = "";
|
61
|
+
}
|
62
|
+
else if (level === 2) {
|
63
|
+
// H2 is a child of the current H1
|
64
|
+
if (currentH1) {
|
65
|
+
parentHash = currentH1.hash;
|
66
|
+
currentH1.children.push(hash);
|
67
|
+
contextTitle = `${plainText} (${currentH1.title})`;
|
68
|
+
}
|
69
|
+
currentH2 = newHeading;
|
70
|
+
currentH3 = null;
|
71
|
+
}
|
72
|
+
else if (level === 3) {
|
73
|
+
// H3 is a child of the current H2, or directly of H1 if no H2 exists
|
74
|
+
if (currentH2) {
|
75
|
+
parentHash = currentH2.hash;
|
76
|
+
currentH2.children.push(hash);
|
77
|
+
contextTitle = `${plainText} (${currentH2.title})`;
|
78
|
+
}
|
79
|
+
else if (currentH1) {
|
80
|
+
parentHash = currentH1.hash;
|
81
|
+
currentH1.children.push(hash);
|
82
|
+
contextTitle = `${plainText} (${currentH1.title})`;
|
83
|
+
}
|
84
|
+
currentH3 = newHeading;
|
85
|
+
}
|
86
|
+
// Check for duplicates before adding to TOC
|
78
87
|
const existingTocIndex = tableOfContents.findIndex((toc) => toc.hash === hash);
|
79
88
|
if (existingTocIndex === -1) {
|
80
|
-
// TOC
|
89
|
+
// Add new TOC entry
|
81
90
|
tableOfContents.push({
|
82
91
|
type: block.type,
|
83
92
|
hash,
|
package/dist/util/tocHelper.d.ts
CHANGED
@@ -23,7 +23,7 @@ export declare const optimizeTocArray: (tocEntries: TocEntry[], reporter: Report
|
|
23
23
|
buildHierarchy?: boolean;
|
24
24
|
}) => TocEntry[];
|
25
25
|
/**
|
26
|
-
* TOC
|
26
|
+
* Validates TOC structure and ensures proper parent-child relationships
|
27
27
|
*/
|
28
28
|
export declare const validateTocStructure: (tocEntries: TocEntry[], reporter: Reporter) => TocEntry[];
|
29
29
|
/**
|
package/dist/util/tocHelper.js
CHANGED
@@ -33,95 +33,42 @@ const optimizeTocArray = (tocEntries, reporter, options = {}) => {
|
|
33
33
|
}
|
34
34
|
return entry;
|
35
35
|
});
|
36
|
-
//
|
36
|
+
// Validate structure and build hierarchy
|
37
37
|
const validatedToc = (0, exports.validateTocStructure)(enrichedTocEntries, reporter);
|
38
38
|
// Remove duplicates if requested
|
39
39
|
let processedToc = validatedToc;
|
40
40
|
if (removeDuplicates) {
|
41
41
|
const startTime = Date.now();
|
42
|
-
//
|
42
|
+
// Map to track unique entries by hash
|
43
43
|
const uniqueMap = new Map();
|
44
|
-
//
|
45
|
-
const h1Entries = new Map(); // 최상위 항목
|
46
|
-
const childEntries = new Map(); // 상위 해시 -> 하위 해시 세트
|
47
|
-
// 1. 먼저 모든 H1 항목을 수집하고 맵에 저장
|
44
|
+
// First collect H1 entries (top-level sections)
|
48
45
|
for (const entry of validatedToc) {
|
49
46
|
if (entry.level === 1) {
|
50
|
-
|
51
|
-
childEntries.set(entry.hash, new Set());
|
47
|
+
uniqueMap.set(entry.hash, entry);
|
52
48
|
}
|
53
49
|
}
|
54
|
-
//
|
50
|
+
// Then collect child entries (H2, H3) that have valid parents
|
55
51
|
for (const entry of validatedToc) {
|
56
|
-
|
57
|
-
|
58
|
-
uniqueMap.
|
59
|
-
|
60
|
-
}
|
61
|
-
// H2, H3 항목 처리
|
62
|
-
if (entry.parentHash) {
|
63
|
-
// 부모 해시가 있는 경우 부모가 실제로 존재하는지 확인
|
64
|
-
const parentExists = uniqueMap.has(entry.parentHash) || h1Entries.has(entry.parentHash);
|
52
|
+
if (entry.level !== 1 && entry.parentHash) {
|
53
|
+
// Only add entries with valid parents to ensure proper hierarchy
|
54
|
+
const parentExists = uniqueMap.has(entry.parentHash) ||
|
55
|
+
validatedToc.some((e) => e.hash === entry.parentHash);
|
65
56
|
if (parentExists) {
|
66
|
-
//
|
67
|
-
if (
|
68
|
-
|
57
|
+
// Add to unique map if not already there
|
58
|
+
if (!uniqueMap.has(entry.hash)) {
|
59
|
+
uniqueMap.set(entry.hash, entry);
|
69
60
|
}
|
70
|
-
else {
|
71
|
-
childEntries.set(entry.parentHash, new Set([entry.hash]));
|
72
|
-
}
|
73
|
-
// 항목을 유효한 것으로 추가
|
74
|
-
uniqueMap.set(entry.hash, entry);
|
75
61
|
}
|
76
62
|
else {
|
77
|
-
|
78
|
-
reporter.warn(`Skipping orphaned TOC entry: ${entry.title} (parent hash ${entry.parentHash} not found)`);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
else if (entry.level === 2) {
|
82
|
-
// H2 항목이지만 부모 해시가 없는 경우 (비정상)
|
83
|
-
reporter.warn(`Skipping H2 entry without parent: ${entry.title}`);
|
84
|
-
}
|
85
|
-
else {
|
86
|
-
// 부모 해시가 없지만 유효할 수 있는 항목
|
87
|
-
uniqueMap.set(entry.hash, entry);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
// 내부 일관성 검사: 동일한 제목의 항목이 여러 섹션에 있는 경우
|
91
|
-
const titleToSections = new Map();
|
92
|
-
for (const entry of uniqueMap.values()) {
|
93
|
-
if (entry.level === 2) {
|
94
|
-
const title = entry.title.toLowerCase();
|
95
|
-
if (!titleToSections.has(title)) {
|
96
|
-
titleToSections.set(title, new Set());
|
97
|
-
}
|
98
|
-
// 이 제목이 속한 부모 H1 추적
|
99
|
-
if (entry.parentHash) {
|
100
|
-
titleToSections.get(title).add(entry.parentHash);
|
63
|
+
reporter.warn(`Skipping orphaned TOC entry: ${entry.title}`);
|
101
64
|
}
|
102
65
|
}
|
103
66
|
}
|
104
|
-
// 여러 섹션에 동일한 제목의 H2가 있는지 확인하고, 영향받는 H2의 contextTitle을 더 강화
|
105
|
-
for (const [title, sections] of titleToSections.entries()) {
|
106
|
-
if (sections.size > 1) {
|
107
|
-
reporter.info(`Title "${title}" appears across ${sections.size} different sections. Enhancing context.`);
|
108
|
-
// 해당 제목의 모든 항목에 대해 상위 항목의 제목을 컨텍스트에 추가
|
109
|
-
for (const entry of uniqueMap.values()) {
|
110
|
-
if (entry.title.toLowerCase() === title && entry.parentHash) {
|
111
|
-
const parentEntry = h1Entries.get(entry.parentHash);
|
112
|
-
if (parentEntry) {
|
113
|
-
entry.contextTitle = `${entry.title} (${parentEntry.title})`;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
}
|
119
|
-
// 최종 결과를 배열로 변환
|
120
67
|
processedToc = Array.from(uniqueMap.values());
|
121
68
|
const removedCount = validatedToc.length - processedToc.length;
|
122
69
|
const processTime = Date.now() - startTime;
|
123
70
|
if (removedCount > 0) {
|
124
|
-
reporter.info(`Removed ${removedCount} duplicate
|
71
|
+
reporter.info(`Removed ${removedCount} duplicate TOC entries in ${processTime}ms.`);
|
125
72
|
}
|
126
73
|
}
|
127
74
|
// Add context to duplicate title entries for better display
|
@@ -135,14 +82,14 @@ const optimizeTocArray = (tocEntries, reporter, options = {}) => {
|
|
135
82
|
}
|
136
83
|
// Build the hierarchical structure if requested
|
137
84
|
if (buildHierarchy) {
|
138
|
-
//
|
85
|
+
// Sort by level for proper hierarchy building
|
139
86
|
processedToc.sort((a, b) => {
|
140
87
|
if ((a.level || 0) !== (b.level || 0)) {
|
141
88
|
return (a.level || 0) - (b.level || 0);
|
142
89
|
}
|
143
90
|
return 0; // Keep original order for same level
|
144
91
|
});
|
145
|
-
//
|
92
|
+
// Log the TOC structure
|
146
93
|
const h1Count = processedToc.filter((item) => item.level === 1).length;
|
147
94
|
const h2Count = processedToc.filter((item) => item.level === 2).length;
|
148
95
|
const h3Count = processedToc.filter((item) => item.level === 3).length;
|
@@ -152,103 +99,80 @@ const optimizeTocArray = (tocEntries, reporter, options = {}) => {
|
|
152
99
|
};
|
153
100
|
exports.optimizeTocArray = optimizeTocArray;
|
154
101
|
/**
|
155
|
-
* TOC
|
102
|
+
* Validates TOC structure and ensures proper parent-child relationships
|
156
103
|
*/
|
157
104
|
const validateTocStructure = (tocEntries, reporter) => {
|
158
105
|
if (!tocEntries || tocEntries.length === 0) {
|
159
106
|
return [];
|
160
107
|
}
|
161
|
-
//
|
162
|
-
const
|
163
|
-
const
|
164
|
-
//
|
108
|
+
// Create maps for efficient lookups
|
109
|
+
const entryMap = new Map();
|
110
|
+
const h1Entries = new Map();
|
111
|
+
// First pass: collect entries by hash
|
165
112
|
for (const entry of tocEntries) {
|
113
|
+
entryMap.set(entry.hash, entry);
|
114
|
+
// Collect H1 entries separately
|
166
115
|
if (entry.level === 1) {
|
167
|
-
|
168
|
-
h1Children.set(entry.hash, new Set());
|
116
|
+
h1Entries.set(entry.hash, entry);
|
169
117
|
}
|
170
118
|
}
|
171
|
-
// H1
|
172
|
-
if (
|
119
|
+
// No H1 entries? Return original
|
120
|
+
if (h1Entries.size === 0) {
|
173
121
|
return tocEntries;
|
174
122
|
}
|
175
|
-
//
|
123
|
+
// Track suspicious entries that might be duplicates
|
124
|
+
const suspiciousEntries = new Set();
|
125
|
+
// Second pass: check parent-child relationships
|
176
126
|
for (const entry of tocEntries) {
|
177
127
|
if (entry.level !== 1 && entry.parentHash) {
|
178
|
-
//
|
179
|
-
if (
|
180
|
-
|
128
|
+
// Check if parent exists
|
129
|
+
if (!entryMap.has(entry.parentHash)) {
|
130
|
+
suspiciousEntries.add(entry.hash);
|
131
|
+
reporter.warn(`Entry ${entry.title} has invalid parent reference`);
|
181
132
|
}
|
182
133
|
}
|
183
134
|
}
|
184
|
-
//
|
185
|
-
const
|
186
|
-
const sectionTitles = new Map();
|
187
|
-
for (const [h1Hash, childHashes] of h1Children.entries()) {
|
188
|
-
const titleCounts = new Map();
|
189
|
-
sectionTitles.set(h1Hash, titleCounts);
|
190
|
-
// 이 H1에 속한 모든 자식 항목 검사
|
191
|
-
for (const entry of tocEntries) {
|
192
|
-
if ((entry.level === 2 || entry.level === 3) &&
|
193
|
-
entry.parentHash === h1Hash) {
|
194
|
-
const title = entry.title.toLowerCase();
|
195
|
-
const count = (titleCounts.get(title) || 0) + 1;
|
196
|
-
titleCounts.set(title, count);
|
197
|
-
// 이 섹션에 이 제목이 이미 있으면 중복으로 표시
|
198
|
-
if (count > 1) {
|
199
|
-
suspiciousEntries.add(entry.hash);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
}
|
203
|
-
}
|
204
|
-
// 5. 다른 섹션에 속할 것으로 보이는 항목 식별 (예: 14. Squid 프록시 서버의 잘못된 자식)
|
205
|
-
const titleToSections = new Map();
|
135
|
+
// Analyze entries with same title but different parents
|
136
|
+
const titleToEntries = new Map();
|
206
137
|
for (const entry of tocEntries) {
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
titleToSections.set(title, new Set());
|
211
|
-
}
|
212
|
-
// 이 제목이 어떤 H1 섹션에 속하는지 기록
|
213
|
-
if (entry.parentHash) {
|
214
|
-
titleToSections.get(title).add(entry.parentHash);
|
215
|
-
}
|
138
|
+
const title = entry.title.toLowerCase();
|
139
|
+
if (!titleToEntries.has(title)) {
|
140
|
+
titleToEntries.set(title, []);
|
216
141
|
}
|
217
|
-
|
218
|
-
|
219
|
-
for
|
220
|
-
|
221
|
-
|
222
|
-
//
|
223
|
-
const
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
suspiciousEntries.add(entry.hash);
|
142
|
+
titleToEntries.get(title).push(entry);
|
143
|
+
}
|
144
|
+
// Check for duplicate titles and mark suspicious if needed
|
145
|
+
for (const [title, entries] of titleToEntries.entries()) {
|
146
|
+
if (entries.length > 1) {
|
147
|
+
// Group entries by parent hash
|
148
|
+
const entriesByParent = new Map();
|
149
|
+
for (const entry of entries) {
|
150
|
+
const parentKey = entry.parentHash || "none";
|
151
|
+
if (!entriesByParent.has(parentKey)) {
|
152
|
+
entriesByParent.set(parentKey, []);
|
153
|
+
}
|
154
|
+
entriesByParent.get(parentKey).push(entry);
|
155
|
+
}
|
156
|
+
// If same title appears under multiple parents
|
157
|
+
if (entriesByParent.size > 1) {
|
158
|
+
reporter.info(`Title "${title}" appears under ${entriesByParent.size} different parents`);
|
159
|
+
// For each parent, keep only the first occurrence
|
160
|
+
for (const [parentHash, parentEntries] of entriesByParent.entries()) {
|
161
|
+
if (parentEntries.length > 1) {
|
162
|
+
// Keep first entry, mark others as suspicious
|
163
|
+
for (let i = 1; i < parentEntries.length; i++) {
|
164
|
+
suspiciousEntries.add(parentEntries[i].hash);
|
241
165
|
}
|
242
166
|
}
|
243
167
|
}
|
244
168
|
}
|
245
169
|
}
|
246
170
|
}
|
247
|
-
//
|
171
|
+
// Report suspicious entries
|
248
172
|
if (suspiciousEntries.size > 0) {
|
249
173
|
reporter.info(`Found ${suspiciousEntries.size} suspicious TOC entries that might be duplicates`);
|
250
174
|
}
|
251
|
-
//
|
175
|
+
// Return filtered TOC with suspicious entries removed
|
252
176
|
return tocEntries.filter((entry) => !suspiciousEntries.has(entry.hash));
|
253
177
|
};
|
254
178
|
exports.validateTocStructure = validateTocStructure;
|
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.2.
|
4
|
+
"version": "1.2.9",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|