diff --git a/src/services/export/tar.js b/src/services/export/tar.js
index c636dedc7..db8ffbc02 100644
--- a/src/services/export/tar.js
+++ b/src/services/export/tar.js
@@ -281,7 +281,7 @@ ${content}
}
}
- function saveNavigation(rootMeta) {
+ function saveNavigation(rootMeta, navigationMeta) {
function saveNavigationInner(meta) {
let html = '
';
@@ -290,7 +290,7 @@ ${content}
if (meta.dataFileName) {
const targetUrl = getTargetUrl(meta.noteId, rootMeta);
- html += `${escapedTitle}`;
+ html += `${escapedTitle}`;
}
else {
html += escapedTitle;
@@ -315,22 +315,64 @@ ${content}
pack.entry({name: navigationMeta.dataFileName, size: prettyHtml.length}, prettyHtml);
}
- const rootMeta = await getNoteMeta(branch, { notePath: [] }, ['navigation']);
+ function saveIndex(rootMeta, indexMeta) {
+ let firstNonEmptyNote;
+ let curMeta = rootMeta;
- const navigationMeta = {
- noImport: true,
- dataFileName: "navigation." + (format === 'html' ? 'html' : 'md')
- };
+ while (!firstNonEmptyNote) {
+ if (curMeta.dataFileName) {
+ firstNonEmptyNote = getTargetUrl(curMeta.noteId, rootMeta);
+ }
+
+ if (curMeta.children && curMeta.children.length > 0) {
+ curMeta = curMeta.children[0];
+ }
+ else {
+ break;
+ }
+ }
+
+ const fullHtml = `
+
+
+
+
+
+`;
+
+ pack.entry({name: indexMeta.dataFileName, size: fullHtml.length}, fullHtml);
+ }
+
+ const existingFileNames = format === 'html' ? ['navigation', 'index'] : [];
+ const rootMeta = await getNoteMeta(branch, { notePath: [] }, existingFileNames);
const metaFile = {
formatVersion: 1,
appVersion: packageInfo.version,
- files: [
- rootMeta,
- navigationMeta
- ]
+ files: [ rootMeta ]
};
+ let navigationMeta, indexMeta;
+
+ if (format === 'html') {
+ navigationMeta = {
+ noImport: true,
+ dataFileName: "navigation.html"
+ };
+
+ metaFile.files.push(navigationMeta);
+
+ indexMeta = {
+ noImport: true,
+ dataFileName: "index.html"
+ };
+
+ metaFile.files.push(indexMeta);
+ }
+
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);
@@ -347,7 +389,10 @@ ${content}
await saveNote(rootMeta, '');
- await saveNavigation(rootMeta, navigationMeta);
+ if (format === 'html') {
+ saveNavigation(rootMeta, navigationMeta);
+ saveIndex(rootMeta, indexMeta);
+ }
pack.finalize();
diff --git a/src/services/import/tar.js b/src/services/import/tar.js
index 4e2b52b21..e8118b678 100644
--- a/src/services/import/tar.js
+++ b/src/services/import/tar.js
@@ -233,6 +233,10 @@ async function importTar(taskContext, fileBuffer, importRootNote) {
async function saveNote(filePath, content) {
const {parentNoteMeta, noteMeta} = getMeta(filePath);
+ if (noteMeta && noteMeta.noImport) {
+ return;
+ }
+
const noteId = getNoteId(noteMeta, filePath);
const parentNoteId = await getParentNoteId(filePath, parentNoteMeta);