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; }