From b6d5ff0093c1555a72c10a67d1a607036649abe4 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 19 Dec 2022 21:07:26 +0800 Subject: [PATCH] Fixed error: when switch tags is null --- main.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.ts b/main.ts index 52a46f6..40bc422 100644 --- a/main.ts +++ b/main.ts @@ -9,8 +9,6 @@ import { Setting, normalizePath } from "obsidian"; -import { join } from "path"; -import * as fs from "fs"; import {addIcons} from 'icon'; import { Upload2Notion } from "Upload2Notion"; import {NoticeMConfig} from "Message"; @@ -99,8 +97,11 @@ export default class ObsidianSyncNotionPlugin extends Plugin { async getNowFileMarkdownContent(app: App) { const nowFile = app.workspace.getActiveFile(); - const tags = app.metadataCache.getFileCache(nowFile).frontmatter.tags; - + const { allowTags } = this.settings; + let tags = [] + if (app.metadataCache.getFileCache(nowFile).tags !== undefined && allowTags) { + tags = app.metadataCache.getFileCache(nowFile).frontmatter.tags; + } if (nowFile) { const markDownData = await nowFile.vault.read(nowFile); return {