From 650a9adc6a8559583604cc18f209bf69757b78c7 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 7 Mar 2023 14:23:20 +0800 Subject: [PATCH] feat: custom filenames --- src/main.ts | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main.ts b/src/main.ts index 961dec0..7a5a07b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -49,6 +49,7 @@ interface Settings { endpoint: string; dateHighlightedFormat: string; dateSavedFormat: string; + filename: string; } const DEFAULT_SETTINGS: Settings = { dateHighlightedFormat: "yyyy-MM-dd HH:mm:ss", @@ -80,6 +81,7 @@ const DEFAULT_SETTINGS: Settings = { folder: "Omnivore/{{date}}", folderDateFormat: "yyyy-MM-dd", endpoint: "https://api-prod.omnivore.app/api/graphql", + filename: "{{{title}}}", }; export default class OmnivorePlugin extends Plugin { @@ -532,15 +534,20 @@ class OmnivoreSettingTab extends PluginSettingTab { }); }); - containerEl.createEl("h3", { - cls: "collapsible", - text: "Advanced Settings", - }); - - const advancedSettings = containerEl.createEl("div", { - cls: "content", - }); - + new Setting(generalSettings) + .setName("Filename") + .setDesc( + "Enter the filename where the data will be stored. {{{title}}} and {{date}} could be used in the filename" + ) + .addText((text) => + text + .setPlaceholder("Enter the filename") + .setValue(this.plugin.settings.filename) + .onChange(async (value) => { + this.plugin.settings.filename = value; + await this.plugin.saveSettings(); + }) + ); new Setting(generalSettings) .setName("Folder Date Format") .setDesc( @@ -584,6 +591,15 @@ class OmnivoreSettingTab extends PluginSettingTab { }) ); + containerEl.createEl("h3", { + cls: "collapsible", + text: "Advanced Settings", + }); + + const advancedSettings = containerEl.createEl("div", { + cls: "content", + }); + new Setting(advancedSettings) .setName("API Endpoint") .setDesc("Enter the Omnivore server's API endpoint")