Skip to content

Build your personal knowledge base with Trilium Notes

fix(export): leave anchor labels out of the export metadata

Elian Doran5460e41d2bad
diff --git a/packages/trilium-core/src/services/export/zip.spec.ts b/packages/trilium-core/src/services/export/zip.spec.ts
index affcc3cfd8..00490e51fc 100644
--- a/packages/trilium-core/src/services/export/zip.spec.ts
+++ b/packages/trilium-core/src/services/export/zip.spec.ts
@@ -266,6 +266,7 @@ describe.skipIf(isBrowserRuntime)("zip export (real DB)", () => {
getContext().init(() => {
note.addRelation("internalLink", target.noteId);
note.addRelation("imageLink", target.noteId);
+ note.addLabel("internalBookmark", "intro");
// The importer reads these two back to remap note ids inside the content.
note.addRelation("includeNoteLink", target.noteId);
note.addRelation("relationMapLink", target.noteId);
@@ -279,6 +280,7 @@ describe.skipIf(isBrowserRuntime)("zip export (real DB)", () => {
expect(names).not.toContain("internalLink");
expect(names).not.toContain("imageLink");
+ expect(names).not.toContain("internalBookmark");
expect(names).toContain("includeNoteLink");
expect(names).toContain("relationMapLink");
expect(names).toContain("userRelation");
diff --git a/packages/trilium-core/src/services/export/zip.ts b/packages/trilium-core/src/services/export/zip.ts
index bc93d8899c..09281b04cd 100644
--- a/packages/trilium-core/src/services/export/zip.ts
+++ b/packages/trilium-core/src/services/export/zip.ts
@@ -589,13 +589,15 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch,
/**
* Whether the importer discards the attribute and rebuilds it from the note's content, which
- * `saveLinks()` does for `internalLink` and `imageLink`. Exporting those writes a set nothing reads
- * back, in an order that differs between a note the editor has appended a link to and the same note
- * derived on import. `includeNoteLink` and `relationMapLink` stay: `services/import/zip.ts` reads
- * them to remap note ids inside the content it imports.
+ * `saveLinks()` does for `internalLink`, `imageLink` and the `internalBookmark` labels. Exporting
+ * those writes a set nothing reads back, in an order that differs between a note the editor has
+ * appended a link to and the same note derived on import. `includeNoteLink` and `relationMapLink`
+ * stay: `services/import/zip.ts` reads them to remap note ids inside the content it imports.
*/
function isRebuiltOnImport(attribute: BAttribute): boolean {
- return attribute.type === "relation" && ["internalLink", "imageLink"].includes(attribute.name);
+ return attribute.type === "relation"
+ ? [ "internalLink", "imageLink" ].includes(attribute.name)
+ : attribute.name === "internalBookmark";
}
/** Counts the notes in a metadata tree — i.e. the number of `saveNote()` calls the content-writing pass will make. */