From 29e81bc97f587bd2d5bceeceff8e10cdbc433e07 Mon Sep 17 00:00:00 2001 From: Hyeonseo Nam Date: Mon, 20 Mar 2023 01:03:03 +0900 Subject: [PATCH] Edit view-manager: edit getFrontMatter to json fromat --- src/view-manager.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/view-manager.ts b/src/view-manager.ts index 17b0801..a634b7c 100644 --- a/src/view-manager.ts +++ b/src/view-manager.ts @@ -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 | null> { + async getFrontMatter(): Promise { 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; }