Fix function for getting the folder of a folder note

This commit is contained in:
Paul 2026-03-26 15:22:04 +01:00
parent 86bd49d873
commit 2683ee1a1a
2 changed files with 9 additions and 2 deletions

View file

@ -188,11 +188,11 @@ async function updateFolderNamesInPath(
const folderNote = getFolderNote(plugin, folderPath);
const viewHeaderTitle = titleContainer.querySelector('.view-header-title');
if (viewHeaderTitle) {
if (viewHeaderTitle && folderNote) {
const filePath = path + (viewHeaderTitle as HTMLElement).innerText.trim() + '.md';
const file = plugin.app.vault.getAbstractFileByPath(
filePath);
const folder = getFolderNoteFolder(plugin, file?.path ?? '', file?.name ?? '');
const folder = getFolderNoteFolder(plugin, folderNote, file?.name ?? '');
if (folder && file && file.path === folderNote?.path && file.parent?.path !== '/') {
viewHeaderTitle.parentElement?.classList.add('hide-folder-note-title-in-path');
viewHeaderTitle.classList.add('path-is-folder-note');

View file

@ -556,6 +556,13 @@ export function getFolderNoteFolder(
filePath = folderNote.path;
}
const folderName = extractFolderName(plugin.settings.folderNoteName, fileName);
if (!plugin.settings.folderNoteName.includes('{{folder_name}}') && plugin.settings.storageLocation === 'insideFolder') {
if (folderNote instanceof TFile) {
return folderNote.parent;
}
const file = plugin.app.vault.getAbstractFileByPath(filePath);
return file instanceof TFile ? file.parent : null;
}
if (!folderName) return null;
let folderPath = getFolderPathFromString(filePath);
if (plugin.settings.storageLocation === 'parentFolder') {