gatsby-source-notion-churnotion 1.2.6 → 1.2.7
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 +81 -89
- package/package.json +1 -1
package/dist/util/resolvers.js
CHANGED
@@ -26,108 +26,100 @@ const formatTableOfContents = (tableOfContents, reporter) => {
|
|
26
26
|
entry.contextTitle = entry.title;
|
27
27
|
}
|
28
28
|
}
|
29
|
-
//
|
30
|
-
const
|
31
|
-
|
32
|
-
const
|
33
|
-
//
|
34
|
-
const
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
for (const h2 of commandHeadings) {
|
39
|
-
if (h2.parentHash) {
|
40
|
-
const h2List = h1ToH2Map.get(h2.parentHash) || [];
|
41
|
-
h2List.push(h2);
|
42
|
-
h1ToH2Map.set(h2.parentHash, h2List);
|
29
|
+
// H1 섹션별 명령어 매핑 & 실제 자식 항목 분석
|
30
|
+
const h1Sections = new Map(); // H1 해시 -> H1 항목
|
31
|
+
const h1Children = new Map(); // H1 해시 -> H2 자식 해시 세트
|
32
|
+
const h2Children = new Map(); // H2 해시 -> H3 자식 해시 세트
|
33
|
+
// 1단계: 모든 H1 항목 수집
|
34
|
+
for (const entry of sortedToc) {
|
35
|
+
if (entry.level === 1) {
|
36
|
+
h1Sections.set(entry.hash, entry);
|
37
|
+
h1Children.set(entry.hash, new Set());
|
43
38
|
}
|
44
39
|
}
|
45
|
-
//
|
46
|
-
const
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if (h3.parentHash) {
|
54
|
-
const h3List = h2ToH3Map.get(h3.parentHash) || [];
|
55
|
-
h3List.push(h3);
|
56
|
-
h2ToH3Map.set(h3.parentHash, h3List);
|
40
|
+
// 2단계: 정당한 H2 항목 식별 (H1의 직접 자식)
|
41
|
+
for (const entry of sortedToc) {
|
42
|
+
if (entry.level === 2 &&
|
43
|
+
entry.parentHash &&
|
44
|
+
h1Sections.has(entry.parentHash)) {
|
45
|
+
// H1의 자식으로 추가
|
46
|
+
h1Children.get(entry.parentHash).add(entry.hash);
|
47
|
+
h2Children.set(entry.hash, new Set());
|
57
48
|
}
|
58
49
|
}
|
59
|
-
//
|
60
|
-
const
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
const commonSubheadings = [
|
66
|
-
"요약",
|
67
|
-
"개요",
|
68
|
-
"설명",
|
69
|
-
"옵션",
|
70
|
-
"문법",
|
71
|
-
"주요 명령어",
|
72
|
-
"주요 속성 설명",
|
73
|
-
"설치",
|
74
|
-
"기본 명령",
|
75
|
-
];
|
76
|
-
// Add common subheadings to the set
|
77
|
-
for (const title of commonSubheadings) {
|
78
|
-
allH3Titles.add(title);
|
79
|
-
}
|
80
|
-
reporter.info(`Found ${allH3Titles.size} unique h3 titles across sections`);
|
81
|
-
// For each command, ensure all common subheadings exist
|
82
|
-
const finalToc = [...sortedToc];
|
83
|
-
let addedEntries = 0;
|
84
|
-
// Create a map of known title combinations to avoid duplicates
|
85
|
-
const knownCombinations = new Set();
|
86
|
-
// Add all existing combinations to the known set
|
87
|
-
for (const entry of subheadings) {
|
88
|
-
if (entry.parentHash) {
|
89
|
-
const parentCommand = commandHeadings.find((h2) => h2.hash === entry.parentHash);
|
90
|
-
if (parentCommand) {
|
91
|
-
const combo = `${parentCommand.title}:${entry.title}`;
|
92
|
-
knownCombinations.add(combo);
|
50
|
+
// 3단계: 정당한 H3 항목 식별 (H2의 직접 자식)
|
51
|
+
for (const entry of sortedToc) {
|
52
|
+
if (entry.level === 3 && entry.parentHash) {
|
53
|
+
// 부모가 H2인 경우
|
54
|
+
if (h2Children.has(entry.parentHash)) {
|
55
|
+
h2Children.get(entry.parentHash).add(entry.hash);
|
93
56
|
}
|
94
57
|
}
|
95
58
|
}
|
96
|
-
//
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
if (
|
105
|
-
|
59
|
+
// 4단계: 각 H1 섹션 내에서 일반적인 명령어 이름이 실제 내용을 가지는지 확인
|
60
|
+
const commandSections = new Map(); // H1 해시 -> (명령어 이름 -> 유효성)
|
61
|
+
const duplicateCommandNames = new Set();
|
62
|
+
// 모든 섹션에서 명령어 이름 수집
|
63
|
+
for (const entry of sortedToc) {
|
64
|
+
if (entry.level === 2) {
|
65
|
+
// 일반적인 명령어 이름인지 확인
|
66
|
+
const isCommonCommand = /^(cp|mv|rm|find|grep|curl|wget|ls|chmod|chown|ps|sed|awk|cat|service|file|locate|stat)$/.test(entry.title.toLowerCase());
|
67
|
+
if (isCommonCommand) {
|
68
|
+
duplicateCommandNames.add(entry.title.toLowerCase());
|
69
|
+
// 이 명령어가 실제 H3 자식을 가지는지 확인
|
70
|
+
const hasChildren = !!(entry.parentHash &&
|
71
|
+
h2Children.has(entry.hash) &&
|
72
|
+
h2Children.get(entry.hash).size > 0);
|
73
|
+
// 섹션별 명령어 유효성 추적
|
74
|
+
if (entry.parentHash) {
|
75
|
+
if (!commandSections.has(entry.parentHash)) {
|
76
|
+
commandSections.set(entry.parentHash, new Map());
|
77
|
+
}
|
78
|
+
commandSections
|
79
|
+
.get(entry.parentHash)
|
80
|
+
.set(entry.title.toLowerCase(), hasChildren);
|
81
|
+
}
|
106
82
|
}
|
107
|
-
// We don't have this subheading for this command - but don't add synthetic entries
|
108
|
-
// in this implementation as we want to show only what's actually in the document
|
109
83
|
}
|
110
84
|
}
|
111
|
-
//
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
85
|
+
// 5단계: 유효하지 않은 명령어 항목 필터링
|
86
|
+
const invalidEntries = new Set();
|
87
|
+
// Squid 프록시 서버와 같은 특정 섹션의 특별 처리
|
88
|
+
const squidSectionEntry = sortedToc.find((entry) => entry.level === 1 && entry.title.includes("Squid 프록시 서버"));
|
89
|
+
if (squidSectionEntry) {
|
90
|
+
const squidSectionHash = squidSectionEntry.hash;
|
91
|
+
const squidCommandStatus = commandSections.get(squidSectionHash);
|
92
|
+
// Squid 섹션의 모든 H2 항목 검토
|
93
|
+
for (const entry of sortedToc) {
|
94
|
+
if (entry.level === 2 && entry.parentHash === squidSectionHash) {
|
95
|
+
// 일반적인 명령어 이름이면서 실제 내용(H3 자식)이 없는 항목은 제거 대상
|
96
|
+
const isCommonCommand = /^(cp|mv|rm|find|grep|curl|wget|ls|chmod|chown|ps|sed|awk|cat|service|file|locate|stat)$/.test(entry.title.toLowerCase());
|
97
|
+
// Squid 섹션 특성에 맞지 않는 일반 명령어 식별
|
98
|
+
if (isCommonCommand) {
|
99
|
+
// 이 명령어가 Squid 섹션에서 정당한 내용을 가지는지 확인
|
100
|
+
const hasValidChildren = !!(entry.hash &&
|
101
|
+
h2Children.has(entry.hash) &&
|
102
|
+
h2Children.get(entry.hash).size > 0);
|
103
|
+
// 내용 없는 명령어는 제거
|
104
|
+
if (!hasValidChildren) {
|
105
|
+
invalidEntries.add(entry.hash);
|
106
|
+
// 이 명령어의 모든 자식도 제거 (혹시 있을 경우)
|
107
|
+
for (const childEntry of sortedToc) {
|
108
|
+
if (childEntry.parentHash === entry.hash) {
|
109
|
+
invalidEntries.add(childEntry.hash);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
127
114
|
}
|
128
115
|
}
|
129
116
|
}
|
130
|
-
|
117
|
+
// 유효하지 않은 항목 제외한 결과 생성
|
118
|
+
const validToc = sortedToc.filter((entry) => !invalidEntries.has(entry.hash));
|
119
|
+
if (invalidEntries.size > 0) {
|
120
|
+
reporter.info(`Removed ${invalidEntries.size} invalid TOC entries from special sections`);
|
121
|
+
}
|
122
|
+
return validToc;
|
131
123
|
}
|
132
124
|
catch (error) {
|
133
125
|
reporter.error(`Error formatting table of contents: ${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.2.
|
4
|
+
"version": "1.2.7",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|