generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from joerncodes/develop
v0.0.4 - Develop into master
- Loading branch information
Showing
20 changed files
with
273 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default interface ObsidianToReaderSettingsInterface { | ||
accessToken: string; | ||
generalTags: string[]; | ||
frontmatter: boolean; | ||
omitFrontmatter: boolean; | ||
fallbackAuthor?: string; | ||
noteTags: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {CachedMetadata, TagCache} from "obsidian"; | ||
import FrontmatterParser from "./frontmatter/frontmatterparser"; | ||
import {FRONTMATTER_KEYS} from "./constants"; | ||
import ObsidianToReaderSettingsInterface from "./settings/obsidiantoreadersettingsinterface"; | ||
|
||
export default class TagCollector | ||
{ | ||
private markdown:string; | ||
private metadata:CachedMetadata; | ||
private settings:ObsidianToReaderSettingsInterface; | ||
|
||
constructor(markdown:string, metadata:CachedMetadata, settings:ObsidianToReaderSettingsInterface) { | ||
this.markdown = markdown; | ||
this.metadata = metadata; | ||
this.settings = settings; | ||
} | ||
|
||
gatherTags():string[] { | ||
let tags:string[] = []; | ||
tags = tags.concat(this.settings.generalTags); | ||
|
||
if(this.settings.noteTags) { | ||
const parser = new FrontmatterParser(this.markdown); | ||
if (parser.hasFrontmatter(FRONTMATTER_KEYS.tags)) { | ||
tags = tags.concat(parser.getFrontmatter(FRONTMATTER_KEYS.tags)?.getValue() || []); | ||
} | ||
|
||
// Omit the # | ||
if(this.metadata.tags !== undefined) { | ||
const metadataTags = this.metadata.tags.map((t:TagCache) => { | ||
return t.tag.startsWith('#') | ||
? t.tag.substring(1) | ||
: t.tag; | ||
}); | ||
tags = tags.concat(metadataTags); | ||
} | ||
} | ||
|
||
return tags; | ||
} | ||
} |
Oops, something went wrong.