feat: publish modal, settings tab, plugin entry
Co-Authored-By: Claude
This commit is contained in:
46
src/SettingsTab.ts
Normal file
46
src/SettingsTab.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { App, PluginSettingTab, Setting } from "obsidian";
|
||||
import type JekyllPublishPlugin from "./main";
|
||||
|
||||
export class JekyllPublishSettingTab extends PluginSettingTab {
|
||||
constructor(app: App, private plugin: JekyllPublishPlugin) {
|
||||
super(app, plugin);
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
const s = this.plugin.settings;
|
||||
const save = () => this.plugin.saveSettings();
|
||||
|
||||
new Setting(containerEl).setName("Remote URL").setDesc("https:// or ssh:// git URL")
|
||||
.addText((t) => t.setValue(s.remoteUrl).onChange((v) => { s.remoteUrl = v; save(); }));
|
||||
new Setting(containerEl).setName("Branch")
|
||||
.addText((t) => t.setValue(s.branch).onChange((v) => { s.branch = v; save(); }));
|
||||
new Setting(containerEl).setName("Posts directory")
|
||||
.addText((t) => t.setValue(s.postsDir).onChange((v) => { s.postsDir = v; save(); }));
|
||||
new Setting(containerEl).setName("Images directory")
|
||||
.addText((t) => t.setValue(s.imagesDir).onChange((v) => { s.imagesDir = v; save(); }));
|
||||
new Setting(containerEl).setName("Default image strategy")
|
||||
.addDropdown((d) => d.addOption("flat-slug", "Flat, renamed to slug")
|
||||
.addOption("per-post-folder", "Per-post subfolder")
|
||||
.setValue(s.defaultImageStrategy)
|
||||
.onChange((v) => { s.defaultImageStrategy = v as typeof s.defaultImageStrategy; save(); }));
|
||||
new Setting(containerEl).setName("Commit message template").setDesc("{{title}} is substituted")
|
||||
.addText((t) => t.setValue(s.commitMessageTemplate).onChange((v) => { s.commitMessageTemplate = v; save(); }));
|
||||
new Setting(containerEl).setName("Author name (optional)")
|
||||
.addText((t) => t.setValue(s.authorName).onChange((v) => { s.authorName = v; save(); }));
|
||||
new Setting(containerEl).setName("Author email (optional)")
|
||||
.addText((t) => t.setValue(s.authorEmail).onChange((v) => { s.authorEmail = v; save(); }));
|
||||
|
||||
containerEl.createEl("h3", { text: "Preset frontmatter" });
|
||||
s.presetFrontmatter.forEach((row, i) => {
|
||||
new Setting(containerEl)
|
||||
.addText((t) => t.setPlaceholder("key").setValue(row.key).onChange((v) => { s.presetFrontmatter[i].key = v; save(); }))
|
||||
.addText((t) => t.setPlaceholder("value").setValue(row.value).onChange((v) => { s.presetFrontmatter[i].value = v; save(); }))
|
||||
.addExtraButton((b) => b.setIcon("trash").onClick(() => { s.presetFrontmatter.splice(i, 1); save(); this.display(); }));
|
||||
});
|
||||
new Setting(containerEl).addButton((b) =>
|
||||
b.setButtonText("Add preset property").onClick(() => { s.presetFrontmatter.push({ key: "", value: "" }); save(); this.display(); })
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user