diff --git a/src/main.ts b/src/main.ts index 4c3603c..9fc0524 100644 --- a/src/main.ts +++ b/src/main.ts @@ -204,6 +204,11 @@ export default class JustSharePleasePlugin extends Plugin { if (this.settings.stripFrontmatter) text = text.replace(/^---\s*\n.*?\n---\s*\n(.*)$/s, "$1"); + // include note name + if (this.settings.includeNoteName) { + text = `# ${file.basename}\n\n${text}`; + } + // embed attachments directly let attachments = /!\[(.*)]\((.+)\)|!\[\[(.+)]]/g; let match: RegExpExecArray; diff --git a/src/settings-tab.ts b/src/settings-tab.ts index af6d60d..b0d1791 100644 --- a/src/settings-tab.ts +++ b/src/settings-tab.ts @@ -43,6 +43,17 @@ export class JSPSettingsTab extends PluginSettingTab { }); }); + new Setting(this.containerEl) + .setName("Include Note Name") + .setDesc("Whether the name of the shared note should be included in the share as a heading.") + .addToggle(t => { + t.setValue(this.plugin.settings.includeNoteName); + t.onChange(async v => { + this.plugin.settings.includeNoteName = v; + await this.plugin.saveSettings(); + }); + }); + this.containerEl.createEl("hr"); this.containerEl.createEl("p", {text: "If you like this plugin and want to support its development, you can do so through my website by clicking this fancy image!"}); this.containerEl.createEl("a", {href: "https://ellpeck.de/support"}) diff --git a/src/settings.ts b/src/settings.ts index 1bbd863..26aa3f9 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,7 +1,8 @@ export const defaultSettings: JSPSettings = { url: "https://jsp.ellpeck.de", shared: [], - stripFrontmatter: true + stripFrontmatter: true, + includeNoteName: true }; // TODO add a setting for auto-refreshing uploads when saving @@ -11,6 +12,7 @@ export interface JSPSettings { url: string; shared: SharedItem[]; stripFrontmatter: boolean; + includeNoteName: boolean; } diff --git a/test-vault/.obsidian/plugins/just-share-please/data.json b/test-vault/.obsidian/plugins/just-share-please/data.json index 24b6d56..0d5b691 100644 --- a/test-vault/.obsidian/plugins/just-share-please/data.json +++ b/test-vault/.obsidian/plugins/just-share-please/data.json @@ -1,16 +1,6 @@ { - "url": "https://jsp.ellpeck.de", - "shared": [ - { - "id": "3c781ebc", - "password": "7eae9eea1f7503f6f236b242d45657e6", - "path": "Cool Test Note.md" - }, - { - "id": "d47f7765", - "password": "513115b756d9ddebd3afd6efe4c248c6", - "path": "Even cooler note.md" - } - ], - "stripFrontmatter": true + "url": "http://localhost:8080", + "shared": [], + "stripFrontmatter": true, + "includeNoteName": true } \ No newline at end of file diff --git a/test-vault/Cool Test Note.md b/test-vault/Cool Test Note.md index d2ad601..6186347 100644 --- a/test-vault/Cool Test Note.md +++ b/test-vault/Cool Test Note.md @@ -1,7 +1,6 @@ --- test: yes --- -# Cool Test Note This is a cool test note, my friends!