Skip to content

Commit

Permalink
fix: use default template if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Feb 22, 2023
1 parent 11a0202 commit 7b4f7e4
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,7 @@ const DEFAULT_SETTINGS: Settings = {
filter: "HIGHLIGHTS",
syncAt: "",
customQuery: "",
template: `---
id: {{{id}}}
title: {{{title}}}
{{#author}}
author: {{{author}}}
{{/author}}
{{#labels.length}}
tags:
{{#labels}} - {{{name}}}
{{/labels}}
{{/labels.length}}
date_saved: {{{dateSaved}}}
---
# {{{title}}}
template: `# {{{title}}}
#Omnivore
[Read on Omnivore]({{{omnivoreUrl}}})
Expand Down Expand Up @@ -502,6 +488,7 @@ class OmnivoreSettingTab extends PluginSettingTab {
href: "https://github.com/janl/mustache.js/#templates",
}),
fragment.createEl("br"),
fragment.createEl("br"),
"Available variables: id, title, omnivoreUrl, siteName, originalUrl, author, content, dateSaved, labels.name, highlights.text, highlights.highlightUrl, highlights.note, highlights.dateHighlighted"
);
})
Expand All @@ -511,7 +498,11 @@ class OmnivoreSettingTab extends PluginSettingTab {
.setPlaceholder("Enter the template")
.setValue(this.plugin.settings.template)
.onChange(async (value) => {
this.plugin.settings.template = value;
// TODO: validate template
// if template is empty, use default template
this.plugin.settings.template = value
? value
: DEFAULT_SETTINGS.template;
await this.plugin.saveSettings();
})
);
Expand Down

0 comments on commit 7b4f7e4

Please sign in to comment.