added the ability to include the note title in the note

This commit is contained in:
Ell 2023-08-17 16:08:25 +02:00
parent 0fa6dff2d6
commit 0679f3add8
5 changed files with 23 additions and 16 deletions

View file

@ -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;

View file

@ -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"})

View file

@ -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;
}

View file

@ -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
}

View file

@ -1,7 +1,6 @@
---
test: yes
---
# Cool Test Note
This is a cool test note, my friends!