Skip to content

Commit

Permalink
Merge pull request #2 from Jayby18/master
Browse files Browse the repository at this point in the history
Add support for boolean, number and array frontmatter
  • Loading branch information
mdelobelle authored May 14, 2021
2 parents 04be900 + b4d034a commit 4995c51
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default class SuperchargedLinks extends Plugin {
const value = parseFrontMatterEntry(targetCachedFile.frontmatter, key)
if(typeof value === 'string'){
new_props[key] = value
} else if (typeof value === 'boolean' || typeof value === 'number'){
new_props[key] = value.toString()
} else if (Array.isArray(value)) {
new_props[key] = value.join(', ')
}
}
})
Expand Down Expand Up @@ -118,13 +122,16 @@ class SuperchargedLinksSettingTab extends PluginSettingTab {

new Setting(containerEl)
.setName('Target Attributes')
.setDesc('Frontmatter attributes to target')
.addText(text => text
.setDesc('Frontmatter attributes to target, comma separated')
.addTextArea((text) => {text
.setPlaceholder('Enter attributes as string, comma separated')
.setValue(this.plugin.settings.targetAttributes.join(', '))
.onChange(async (value) => {
this.plugin.settings.targetAttributes = value.replace(/\s/g,'').split(',');
await this.plugin.saveSettings();
}));
})
text.inputEl.rows = 6;
text.inputEl.cols = 25;
});
}
}

0 comments on commit 4995c51

Please sign in to comment.