mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
Merge pull request #10 from n8k99/claude/fix-nested-folder-display-015Ytt8mSX9sfytMQC85P4gA
debug(obsidian): add logging to diagnose nested folder display issue
This commit is contained in:
commit
f8e6f0ba47
2 changed files with 24 additions and 1 deletions
|
|
@ -79,7 +79,15 @@ const ObsidianBridge = (() => {
|
|||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.files || [];
|
||||
const files = data.files || [];
|
||||
|
||||
// Filter to only .md files
|
||||
const mdFiles = files.filter(f => f.endsWith(".md"));
|
||||
|
||||
INFO && console.log(`getVaultFiles: Found ${files.length} total files, ${mdFiles.length} markdown files`);
|
||||
DEBUG && console.log("Sample files:", mdFiles.slice(0, 10));
|
||||
|
||||
return mdFiles;
|
||||
} catch (error) {
|
||||
ERROR && console.error("Failed to get vault files:", error);
|
||||
throw error;
|
||||
|
|
@ -435,6 +443,8 @@ Add your lore here...
|
|||
const allFiles = await getVaultFiles();
|
||||
const notes = [];
|
||||
|
||||
INFO && console.log(`listAllNotes: Processing ${allFiles.length} files`);
|
||||
|
||||
for (const filePath of allFiles) {
|
||||
try {
|
||||
const content = await getNote(filePath);
|
||||
|
|
@ -453,6 +463,10 @@ Add your lore here...
|
|||
|
||||
// Sort by path
|
||||
notes.sort((a, b) => a.path.localeCompare(b.path));
|
||||
|
||||
INFO && console.log(`listAllNotes: Returning ${notes.length} notes`);
|
||||
DEBUG && console.log("Sample note paths:", notes.slice(0, 5).map(n => n.path));
|
||||
|
||||
return notes;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -360,13 +360,18 @@ async function promptCreateNewNote(elementId, elementType, coordinates) {
|
|||
function buildFolderTree(notes) {
|
||||
const root = {folders: {}, files: []};
|
||||
|
||||
INFO && console.log(`buildFolderTree: Processing ${notes.length} notes`);
|
||||
|
||||
notes.forEach((note, index) => {
|
||||
const parts = note.path.split("/");
|
||||
const fileName = parts[parts.length - 1];
|
||||
|
||||
DEBUG && console.log(`Processing note ${index}: ${note.path} (${parts.length} parts)`);
|
||||
|
||||
if (parts.length === 1) {
|
||||
// Root level file
|
||||
root.files.push({name: fileName, index, path: note.path});
|
||||
DEBUG && console.log(` -> Added to root files: ${fileName}`);
|
||||
} else {
|
||||
// Navigate/create folder structure
|
||||
let current = root;
|
||||
|
|
@ -374,14 +379,18 @@ function buildFolderTree(notes) {
|
|||
const folderName = parts[i];
|
||||
if (!current.folders[folderName]) {
|
||||
current.folders[folderName] = {folders: {}, files: []};
|
||||
DEBUG && console.log(` -> Created folder: ${folderName}`);
|
||||
}
|
||||
current = current.folders[folderName];
|
||||
}
|
||||
// Add file to final folder
|
||||
current.files.push({name: fileName, index, path: note.path});
|
||||
DEBUG && console.log(` -> Added to folder: ${fileName}`);
|
||||
}
|
||||
});
|
||||
|
||||
INFO && console.log("Folder tree structure:", root);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue