Skip to content

Commit

Permalink
add a filename date format to help resolve issue #54
Browse files Browse the repository at this point in the history
  • Loading branch information
kinabalu committed Oct 3, 2024
1 parent 40cf9e4 commit bfa8b59
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 2 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DEFAULT_SETTINGS: VoiceNotesPluginSettings = {
deleteSynced: false,
reallyDeleteSynced: false,
todoTag: '',
prependDateFormat: 'YYYY-MM-DD',
filenameDateFormat: 'YYYY-MM-DD',
useDefaultFrontmatter: true,
noteTemplate: `# {{ title }}
Expand Down Expand Up @@ -113,7 +113,6 @@ Date: {{ date }}
`,
excludeTags: [],
dateFormat: 'YYYY-MM-DD',
prependDate: false,
};

export default class VoiceNotesPlugin extends Plugin {
Expand Down Expand Up @@ -223,7 +222,7 @@ export default class VoiceNotesPlugin extends Plugin {
}

sanitizedTitle(title: string, created_at: string): string {
const date = formatDate(created_at, this.settings.prependDateFormat);
const date = formatDate(created_at, this.settings.filenameDateFormat);
const generatedTitle = this.settings.filenameTemplate.replace('{{date}}', date).replace('{{title}}', title);
return sanitize(generatedTitle);
}
Expand Down
13 changes: 13 additions & 0 deletions settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ export class VoiceNotesSettingTab extends PluginSettingTab {
})
);

new Setting(containerEl)
.setName('Filename Date Format')
.setDesc('Format of the date used to replace {{date}} if in Filename Template below (moment.js format)')
.addText((text) =>
text
.setPlaceholder('YYYY-MM-DD')
.setValue(this.plugin.settings.filenameDateFormat)
.onChange(async (value) => {
this.plugin.settings.filenameDateFormat = value;
await this.plugin.saveSettings();
})
);

new Setting(containerEl)
.setName('Filename Template')
.setDesc('Template for the filename of synced notes. Available variables: {{date}}, {{title}}')
Expand Down
3 changes: 1 addition & 2 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ export interface VoiceNotesPluginSettings {
deleteSynced: boolean;
reallyDeleteSynced: boolean;
todoTag: string;
prependDateFormat: string;
filenameDateFormat: string;
useDefaultFrontmatter: boolean;
noteTemplate: string;
filenameTemplate: string;
excludeTags: string[];
dateFormat: string;
prependDate: boolean;
}

export interface UserSettings {
Expand Down

0 comments on commit bfa8b59

Please sign in to comment.