mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
Fix import error (#1060)
* Fix access to attributes on undefined noteMeta * Remove .markdown extension from imported page titles
This commit is contained in:
parent
d65624d8d2
commit
c0cd321118
@ -201,7 +201,7 @@ async function importTar(taskContext, fileBuffer, importRootNote) {
|
|||||||
function getTextFileWithoutExtension(filePath) {
|
function getTextFileWithoutExtension(filePath) {
|
||||||
const extension = path.extname(filePath).toLowerCase();
|
const extension = path.extname(filePath).toLowerCase();
|
||||||
|
|
||||||
if (extension === '.md' || extension === '.html') {
|
if (extension === '.md' || extension === '.markdown' || extension === '.html') {
|
||||||
return filePath.substr(0, filePath.length - extension.length);
|
return filePath.substr(0, filePath.length - extension.length);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -205,7 +205,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
|||||||
function getTextFileWithoutExtension(filePath) {
|
function getTextFileWithoutExtension(filePath) {
|
||||||
const extension = path.extname(filePath).toLowerCase();
|
const extension = path.extname(filePath).toLowerCase();
|
||||||
|
|
||||||
if (extension === '.md' || extension === '.html') {
|
if (extension === '.md' || extension === '.markdown' || extension === '.html') {
|
||||||
return filePath.substr(0, filePath.length - extension.length);
|
return filePath.substr(0, filePath.length - extension.length);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -318,12 +318,14 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const includeNoteLinks = (noteMeta.attributes || [])
|
if(noteMeta) {
|
||||||
.filter(attr => attr.type === 'relation' && attr.name === 'includeNoteLink');
|
const includeNoteLinks = (noteMeta.attributes || [])
|
||||||
|
.filter(attr => attr.type === 'relation' && attr.name === 'includeNoteLink');
|
||||||
|
|
||||||
for (const link of includeNoteLinks) {
|
for (const link of includeNoteLinks) {
|
||||||
// no need to escape the regexp find string since it's a noteId which doesn't contain any special characters
|
// no need to escape the regexp find string since it's a noteId which doesn't contain any special characters
|
||||||
content = content.replace(new RegExp(link.value, "g"), getNewNoteId(link.value));
|
content = content.replace(new RegExp(link.value, "g"), getNewNoteId(link.value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user