Skip to content

Commit f42deca

Browse files
committed
story template.
1 parent f34474b commit f42deca

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/_constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@ export const RFC = {
1616
export const DEFAULT_SETTINGS: HackerNewsSettings = {
1717
defaultRefreshInterval: "60",
1818
storiesFolder: "HackerNews",
19+
storyTemplate: `---
20+
date: {{date}}
21+
source: [{{url}}]({{url}})
22+
23+
---
24+
25+
# {{title}}
26+
---
27+
28+
> notes from [{{title}}]({{url}})
29+
`
1930
}

src/l10n/locale/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export default {
1010
'The time interval in seconds after which the next top story will be fetched. Default and invalid values will be reverted to 60 seconds.': 'The time interval in seconds after which the next top story will be fetched. Default and invalid values will be reverted to 60 seconds.',
1111
'Stories Folder': 'Stories Folder',
1212
'The folder that holds the saved HackerNews stories. The folder will be created if it does not exist.': 'The folder that holds the saved HackerNews stories. The folder will be created if it does not exist.',
13+
'Story Template': 'Story Template',
14+
'Specify how the HackerNews story is saved; available attributes: title, url, date.': 'Specify how the HackerNews story is saved; available attributes: title, url, date.',
1315
'Donate': 'Donate',
1416
'If you found this plugin helpful, consider donating to support continued development.': 'If you found this plugin helpful, consider donating to support continued development.',
1517
};

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface HackerNewsSettings {
22
defaultRefreshInterval: string;
33
storiesFolder: string;
4+
storyTemplate: string;
45
}

src/ui/settings/settingsTab.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ export default class SettingsTab extends PluginSettingTab {
4040
plugin.settings.storiesFolder = value;
4141
await this.save();
4242
}));
43+
new Setting(containerEl)
44+
.setName(t('Story Template'))
45+
.setDesc(t('Specify how the HackerNews story is saved; available attributes: title, url, date.'))
46+
.addTextArea(text => text
47+
.setPlaceholder('stories folder')
48+
.setValue(plugin.settings.storyTemplate)
49+
.onChange(async (value) => {
50+
plugin.settings.storyTemplate = value;
51+
await this.save();
52+
}));
4353
new Setting(containerEl)
4454
.setName(t('Donate'))
4555
.setDesc(t('If you found this plugin helpful, consider donating to support continued development.'))

0 commit comments

Comments
 (0)