diff --git a/src/core/note-goal.ts b/src/core/note-goal.ts index af72ffb..678549a 100644 --- a/src/core/note-goal.ts +++ b/src/core/note-goal.ts @@ -50,7 +50,7 @@ export class NoteGoalHelper { const todaysDailyGoal = await this.goalHistoryHelper.todaysGoalItem(fileOrFolder.path); const result = { path: fileOrFolder.path, - title: fileOrFolder.name.replace('.md', ''), + title: fileOrFolder.name.split('.')[0], goalType: isFile ? GoalType.Note : GoalType.Folder, goalCount: goalCount, dailyGoalCount: dailyGoalCount, @@ -98,6 +98,10 @@ export class NoteGoalHelper { } isFile(fileOrFolder:TAbstractFile){ - return fileOrFolder instanceof TFile && fileOrFolder.extension == "md"; + return fileOrFolder instanceof TFile && (fileOrFolder.extension == "md" || this.additionalFileTypes(fileOrFolder)); + } + + additionalFileTypes(file:TFile) { + return this.settings.additionalFileTypes.contains(file.extension); } } \ No newline at end of file diff --git a/src/core/settings/settings-tab.ts b/src/core/settings/settings-tab.ts index 2e4f289..a6d6cc0 100644 --- a/src/core/settings/settings-tab.ts +++ b/src/core/settings/settings-tab.ts @@ -99,6 +99,26 @@ import { DAILY_GOAL_BAR_COLOR, DAILY_GOAL_FRONTMATTER_KEY, GOAL_BAR_COLOR, GOAL_ this.plugin.loadNoteGoalData(); })); + new Setting(containerEl) + .setName('Additional file types') + .setDesc('Markdown files are included in word counts by default. Add other file types to include in word counts. Comma delimited with only file extension') + .addButton(button => + button + .setButtonText("Reindex") + .setCta() + .onClick(evt => { + this.plugin.loadNoteGoalData(true); + })) + .addTextArea(text => + text + .setValue(this.plugin.settings.additionalFileTypes?.join(',')) + .setPlaceholder('md,') + .onChange(async (value:string) => { + this.plugin.settings.additionalFileTypes = + value.split(',').map(v => v.trim()).filter(v => v && v.length > 0); + await this.plugin.saveData(this.plugin.settings); + })); + new Setting(containerEl) .setName('Exclude comments') .setDesc('Exclude markdown (%% %%) and HTML () comments when counting words') diff --git a/src/core/settings/settings.ts b/src/core/settings/settings.ts index 9cf1dd4..3e455b4 100644 --- a/src/core/settings/settings.ts +++ b/src/core/settings/settings.ts @@ -17,6 +17,7 @@ export class WritingGoalsSettings { allowNegativeGoalProgress: boolean= false; customGoalBarColor: string = GOAL_BAR_COLOR; customDailyGoalBarColor: string = DAILY_GOAL_BAR_COLOR; + additionalFileTypes: string[]; noGoal(path:string): boolean{ return !this.noteGoals.contains(path) && this.folderGoals.filter(fg => fg.path == path).length == 0;