Skip to content

Commit

Permalink
Merge pull request #91 from smithumble/respect-index-filename-on-create
Browse files Browse the repository at this point in the history
Respect user specified indexFilename on folder create
  • Loading branch information
turulix authored Oct 5, 2024
2 parents 98a210e + e1d3d7f commit eb0bc25
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/modules/FolderNoteModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export class FolderNoteModule {
return null
}

private indexFilePathOnClick(dataPath: string) {
private indexFilePath(path: string): string {
if (this.plugin.settings.indexFileUserSpecified) {
return dataPath + "/" + this.plugin.settings.indexFilename + ".md"
return path + "/" + this.plugin.settings.indexFilename + ".md";
} else {
const folderName = dataPath.split("/").pop()
return dataPath + "/" + folderName + ".md"
const folderName = path.split("/").pop();
return path + "/" + folderName + ".md";
}
}

Expand All @@ -82,7 +82,7 @@ export class FolderNoteModule {
dataPath = dataPathAttribute.value
}

let indexFilePath = this.indexFilePathOnClick(dataPath)
let indexFilePath = this.indexFilePath(dataPath)

// This is the root folder, so we open the root index file
if (indexFilePath == "//.md") {
Expand Down Expand Up @@ -225,7 +225,8 @@ export class FolderNoteModule {

private async onCreate(file: TAbstractFile) {
if (file instanceof TFolder) {
await this.createIndexFile(`${file.path}/${file.name}.md`)
const indexFilePath = this.indexFilePath(file.path);
await this.createIndexFile(indexFilePath);
}
}
}

0 comments on commit eb0bc25

Please sign in to comment.