Skip to content

Commit

Permalink
feat: support boolean values in frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisseidel committed Jul 27, 2021
1 parent 3520d0b commit dc63e41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion data.json
@@ -1 +1,8 @@
{"useFrontmatterHighlight":false,"usePathHighlight":true,"frontmatterAttribute":"classification","valueToHighlight":"public","pathToHighlight":"03_ARTICLES","mySetting":"classifcation"}
{
"useFrontmatterHighlight": true,
"usePathHighlight": false,
"frontmatterAttribute": "classification",
"valueToHighlight": "public",
"pathToHighlight": "03_ARTICLES",
"mySetting": "classification"
}
11 changes: 9 additions & 2 deletions main.ts
Expand Up @@ -31,8 +31,11 @@ export default class HighlightpublicnotesPlugin extends Plugin {
return;

if(this.settings.useFrontmatterHighlight) {
const classifcation = this.app.metadataCache.getFileCache(file)?.frontmatter?.[this.settings.frontmatterAttribute]
if (classifcation == this.settings.valueToHighlight) {
const classification = this.app.metadataCache.getFileCache(file)?.frontmatter?.[this.settings.frontmatterAttribute]
const normalizedClassification = classification?.toString().toLowerCase()
const valueToHighlight = this.settings.valueToHighlight
const normalizedValueToHighlight = valueToHighlight?.toString().toLowerCase()
if (normalizedClassification == normalizedValueToHighlight) {
this.highlightNote()
} else {
this.unhighlightNote()
Expand All @@ -46,6 +49,10 @@ export default class HighlightpublicnotesPlugin extends Plugin {
}
}

private getNoteClassification() {

}

private highlightNote() {
const titlebar = document.getElementsByClassName("titlebar")[0]
titlebar.classList.add("myalert")
Expand Down

0 comments on commit dc63e41

Please sign in to comment.