Skip to content

Commit

Permalink
feat: add toggle for export blog tag & static dir can be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kirito41dd committed Nov 25, 2024
1 parent 68c5ef2 commit 908cc44
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "hugo-publish",
"name": "Hugo Publish",
"version": "1.0.6",
"version": "1.0.7",
"minAppVersion": "0.15.0",
"description": "Publish your blog to hugo site.",
"author": "kirito",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-sample-plugin",
"version": "1.0.6",
"version": "1.0.7",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
17 changes: 12 additions & 5 deletions src/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as path from 'path';

export interface HugoPublishSettings {
blog_tag: string;
export_blog_tag: boolean;
site_dir: string; // absolute path
blog_dir: string; // relative path to site_dir
static_dir: string; // relative path to site_dir/static
Expand Down Expand Up @@ -35,7 +36,8 @@ export const DEFAULT_SETTINGS: HugoPublishSettings = {
}
}
return regs;
}
},
export_blog_tag: true
}

export class HugoPublishSettingTab extends PluginSettingTab {
Expand All @@ -61,18 +63,23 @@ export class HugoPublishSettingTab extends PluginSettingTab {
this.plugin.settings.blog_tag = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl).setName("export blog tag").setDesc("Export ${blog tag} to hugo md file's header")
.addToggle(toggle => toggle.setValue(this.plugin.settings.export_blog_tag).onChange(async (value) => {
this.plugin.settings.export_blog_tag = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl).setName("site dir").setDesc("Hugo site root dir, absolute path")
.addText(text => text.setPlaceholder("/path/to/hugo/site").setValue(this.plugin.settings.site_dir).onChange(async (value) => {
this.plugin.settings.site_dir = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl).setName("blog dir").setDesc("All blog copy to this dir, relative path to site")
new Setting(containerEl).setName("blog dir").setDesc("All blog copy to this dir, relative path to site, note that content will be deleted first when syncing")
.addText(text => text.setPlaceholder("blog/dir").setValue(this.plugin.settings.blog_dir).onChange(async (value) => {
this.plugin.settings.blog_dir = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl).setName("static dir").setDesc("All static(like image) copy to static/${static dir}, like static/ob, relative path to site/static")
.addText(text => text.setPlaceholder("static/dir").setValue(this.plugin.settings.static_dir).onChange(async (value) => {
new Setting(containerEl).setName("static dir").setDesc("All static(like images) copy to static/${static dir}, like static/ob, relative path to site/static. Can be empty, note that content will be deleted first when syncing")
.addText(text => text.setPlaceholder("./").setValue(this.plugin.settings.static_dir).onChange(async (value) => {
this.plugin.settings.static_dir = value;
await this.plugin.saveSettings();
}));
Expand All @@ -85,7 +92,7 @@ export class HugoPublishSettingTab extends PluginSettingTab {
}

export const check_setting = (setting: HugoPublishSettings): boolean => {
if (setting.blog_dir.length == 0 || setting.static_dir.length == 0) {
if (setting.blog_dir.length == 0 || setting.site_dir.length == 0) {
return false
}
return true;
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"1.0.3": "0.15.0",
"1.0.4": "0.15.0",
"1.0.5": "0.15.0",
"1.0.6": "0.15.0"
"1.0.6": "0.15.0",
"1.0.7": "0.15.0"
}

0 comments on commit 908cc44

Please sign in to comment.