diff --git a/src/helpers/filetreeUtils.js b/src/helpers/filetreeUtils.js index 2e3e1f281..6cafbf057 100644 --- a/src/helpers/filetreeUtils.js +++ b/src/helpers/filetreeUtils.js @@ -88,10 +88,14 @@ function getPermalinkMeta(note, key) { if (note.data["dg-path"]) { folders = note.data["dg-path"].split("/"); } else { - folders = note.filePathStem - .split("notes/")[1] - .split("/"); - } + // Ensure we extract everything after the LAST "notes/" occurrence + const parts = note.filePathStem.split("/notes/"); + if (parts.length > 1) { + folders = parts.slice(-1)[0].split("/"); // Take the last part after "notes/" + } else { + folders = []; // Handle unexpected cases gracefully + } + } folders[folders.length - 1]+= ".md"; } catch { //ignore