exported links to "named" notes should be preserved upon import

This commit is contained in:
zadam
2022-12-23 23:08:30 +01:00
parent 5ae0a5cf1e
commit 392b89e6dd
6 changed files with 44 additions and 15 deletions

View File

@@ -432,7 +432,18 @@ ${markdownContent}`;
for (const noteMeta of Object.values(noteIdToMeta)) {
// filter out relations which are not inside this export
noteMeta.attributes = noteMeta.attributes.filter(attr => attr.type !== 'relation' || attr.value in noteIdToMeta);
noteMeta.attributes = noteMeta.attributes.filter(attr => {
if (attr.type !== 'relation') {
return true;
} else if (attr.value in noteIdToMeta) {
return true;
} else if (attr.value === 'root' || attr.value?.startsWith("_")) {
// relations to "named" noteIds can be preserved
return true;
} else {
return false;
}
});
}
if (!rootMeta) { // corner case of disabled export for exported note