Skip to content

Commit ddf5860

Browse files
committed
enable via settings
1 parent d415dcb commit ddf5860

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/commands/publishDocument.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async function buildDocumentRecord(plugin: AtmospherePlugin, file: TFile): Promi
102102
publishedAt = fm["publishedAt"]; // Preserve existing if updating
103103
}
104104

105-
if (!title) {
105+
if (!title && plugin.settings.publish.useFirstHeaderAsTitle) {
106106
title = extractFirstH1(content);
107107
}
108108

src/settings.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ export interface AtProtoSettings {
55
identifier: string;
66
appPassword: string;
77
clipDir: string;
8+
publish: {
9+
useFirstHeaderAsTitle: boolean;
10+
};
811
}
912

1013
export const DEFAULT_SETTINGS: AtProtoSettings = {
1114
identifier: "",
1215
appPassword: "",
1316
clipDir: "AtmosphereClips",
17+
publish: {
18+
useFirstHeaderAsTitle: false,
19+
}
1420
};
1521

1622
export class SettingTab extends PluginSettingTab {
@@ -50,6 +56,7 @@ export class SettingTab extends PluginSettingTab {
5056
await this.plugin.saveSettings();
5157
});
5258
});
59+
5360
new Setting(containerEl)
5461
.setName("Clip directory")
5562
.setDesc("Directory in your vault to save clips (will be created if it doesn't exist)")
@@ -61,5 +68,17 @@ export class SettingTab extends PluginSettingTab {
6168
await this.plugin.saveSettings();
6269
})
6370
);
71+
72+
new Setting(containerEl)
73+
.setName("Use first header as publish title")
74+
.setDesc('When enabled and no "title" property is set, first markdown level 1 header will be used as the title of the published document. If disabled, the title will default to the note filename.')
75+
.addToggle((toggle) =>
76+
toggle
77+
.setValue(this.plugin.settings.publish.useFirstHeaderAsTitle)
78+
.onChange(async (value) => {
79+
this.plugin.settings.publish.useFirstHeaderAsTitle = value;
80+
await this.plugin.saveSettings();
81+
})
82+
);
6483
}
6584
}

0 commit comments

Comments
 (0)