From 5b0595631e3ad8639417c8cd08f30704f2509260 Mon Sep 17 00:00:00 2001 From: ShatQ Date: Tue, 3 Dec 2024 12:54:53 +0100 Subject: [PATCH] fix: folder containing 'notes' breaks file tree --- src/helpers/filetreeUtils.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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