mirror of
https://github.com/hyeonseonam/auto-classifier.git
synced 2026-07-22 07:40:29 +00:00
Edit view-manager: edit getFrontMatter to json fromat
This commit is contained in:
parent
fd4adf989a
commit
29e81bc97f
1 changed files with 7 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { App, MarkdownView, Notice, Editor, getAllTags, TagCache} from "obsidian";
|
||||
import { App, MarkdownView, Notice, Editor, getAllTags, TagCache, FrontMatterCache} from "obsidian";
|
||||
|
||||
export class ViewManager {
|
||||
app: App;
|
||||
|
|
@ -26,12 +26,15 @@ export class ViewManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
async getFrontMatter(): Promise<Record<string, unknown> | null> {
|
||||
async getFrontMatter(): Promise<string | null> {
|
||||
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
if (activeView) {
|
||||
const file = activeView.file;
|
||||
const cache = this.app.metadataCache.getFileCache(file);
|
||||
return cache?.frontmatter || null;
|
||||
const frontmatter:FrontMatterCache | undefined = this.app.metadataCache.getFileCache(file)?.frontmatter;
|
||||
if (frontmatter && frontmatter.hasOwnProperty('position')) {
|
||||
delete frontmatter.position;
|
||||
}
|
||||
return JSON.stringify(frontmatter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue