diff --git a/main.ts b/main.ts index 7e998ce..7ac1f70 100644 --- a/main.ts +++ b/main.ts @@ -10,6 +10,7 @@ import { import type moment from "moment"; const DEFAULT_SETTINGS: ChangelogSettings = { + deviceName: undefined, numberOfFilesToShow: 10, changelogFilePath: "", watchVaultChange: false, @@ -83,12 +84,23 @@ export default class Changelog extends Plugin { .sort((a, b) => (a.stat.mtime < b.stat.mtime ? 1 : -1)) .slice(0, this.settings.numberOfFilesToShow); let changelogContent = ``; + let deviceNameSnippet = undefined; + + if(this.settings.deviceName) + { + deviceNameSnippet = `- *${this.settings.deviceName}* on`; + } + else + { + deviceNameSnippet = "- " + } + for (let recentlyEditedFile of recentlyEditedFiles) { // TODO: make date format configurable (and validate it) const humanTime = window .moment(recentlyEditedFile.stat.mtime) .format("YYYY-MM-DD [at] HH[h]mm"); - changelogContent += `- ${humanTime} · [[${recentlyEditedFile.basename}]]\n`; + changelogContent += `${deviceNameSnippet} ${humanTime} · [[${recentlyEditedFile.basename}]]\n`; } return changelogContent; } @@ -116,6 +128,7 @@ export default class Changelog extends Plugin { } interface ChangelogSettings { + deviceName: string; changelogFilePath: string; numberOfFilesToShow: number; watchVaultChange: boolean; @@ -149,6 +162,21 @@ class ChangelogSettingsTab extends PluginSettingTab { }); }); + new Setting(containerEl) + .setName("Device name") + .setDesc( + "Give this device a unique name to record it against items in the change log" + ) + .addText((text) => { + text + .setPlaceholder("Example: Work Laptop") + .setValue(settings.deviceName) + .onChange((value) => { + settings.deviceName = value; + this.plugin.saveSettings(); + }); + }) + new Setting(containerEl) .setName("Number of recent files in changelog") .setDesc("Number of most recently edited files to show in the changelog")