@moxn/kb-migrate 0.4.8 → 0.4.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.
|
@@ -152,11 +152,7 @@ async function createNotionDatabase(ctx, parentPageId, resolved) {
|
|
|
152
152
|
body: {
|
|
153
153
|
parent: { type: 'page_id', page_id: parentPageId },
|
|
154
154
|
title: [{ type: 'text', text: { content: resolved.databaseName } }],
|
|
155
|
-
initial_data_source: {
|
|
156
|
-
type: 'external',
|
|
157
|
-
external: {},
|
|
158
|
-
properties,
|
|
159
|
-
},
|
|
155
|
+
initial_data_source: { properties },
|
|
160
156
|
},
|
|
161
157
|
}));
|
|
162
158
|
const notionDatabaseId = response.id;
|
package/dist/targets/notion.js
CHANGED
|
@@ -46,6 +46,22 @@ function extractKBPathReferences(text) {
|
|
|
46
46
|
});
|
|
47
47
|
return { cleanedText, references };
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Strip invalid internal links from markdown text.
|
|
51
|
+
* Notion rejects links that aren't valid URLs (e.g., relative KB paths
|
|
52
|
+
* like "some/relative/path"). Convert them to plain text.
|
|
53
|
+
*/
|
|
54
|
+
function stripInvalidLinks(text) {
|
|
55
|
+
// Match markdown links [text](url) where url is NOT a valid URL
|
|
56
|
+
return text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, displayText, url) => {
|
|
57
|
+
// Keep links that look like valid URLs (http/https/mailto/tel)
|
|
58
|
+
if (/^(https?:\/\/|mailto:|tel:|#)/.test(url)) {
|
|
59
|
+
return match;
|
|
60
|
+
}
|
|
61
|
+
// Strip relative/internal paths — just keep the display text
|
|
62
|
+
return displayText;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
49
65
|
/**
|
|
50
66
|
* Convert a KB document's sections into a single markdown string.
|
|
51
67
|
* Section names become H2 headings (mirrors the import convention).
|
|
@@ -68,6 +84,9 @@ function sectionsToMarkdown(sections, options) {
|
|
|
68
84
|
text = cleanedText;
|
|
69
85
|
allReferences.push(...references);
|
|
70
86
|
}
|
|
87
|
+
// Strip relative/internal links that aren't valid URLs
|
|
88
|
+
// (Notion rejects links without a protocol)
|
|
89
|
+
text = stripInvalidLinks(text);
|
|
71
90
|
parts.push(text);
|
|
72
91
|
parts.push('');
|
|
73
92
|
}
|
package/package.json
CHANGED