mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 08:08:34 +08:00
Fixed tags bug
This commit is contained in:
@@ -6,12 +6,14 @@ export const NoticeMsg: {[key: string]:any} = {
|
|||||||
"open-notion": "Please open the file that needs to be synchronized",
|
"open-notion": "Please open the file that needs to be synchronized",
|
||||||
"config-secrets-notion-api": "Please set up the notion API in the settings tab.",
|
"config-secrets-notion-api": "Please set up the notion API in the settings tab.",
|
||||||
"config-secrets-database-id": "Please set up the database id in the settings tab.",
|
"config-secrets-database-id": "Please set up the database id in the settings tab.",
|
||||||
|
"set-tags-fail": "Set tags fail,please check the frontmatter of the file or close the tag switch in the settings tab.",
|
||||||
},
|
},
|
||||||
"zh": {
|
"zh": {
|
||||||
"notion-logo": "分享到Notion",
|
"notion-logo": "分享到Notion",
|
||||||
"sync-success": "同步到Notion成功:\n",
|
"sync-success": "同步到Notion成功:\n",
|
||||||
"sync-fail": "同步到Notion失败: \n",
|
"sync-fail": "同步到Notion失败: \n",
|
||||||
"open-file": "请打开需要同步的文件"
|
"open-file": "请打开需要同步的文件",
|
||||||
|
"set-tags-fail": "设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
main.ts
27
main.ts
@@ -12,6 +12,7 @@ import {
|
|||||||
import {addIcons} from 'icon';
|
import {addIcons} from 'icon';
|
||||||
import { Upload2Notion } from "Upload2Notion";
|
import { Upload2Notion } from "Upload2Notion";
|
||||||
import {NoticeMConfig} from "Message";
|
import {NoticeMConfig} from "Message";
|
||||||
|
import { CLIENT_RENEG_LIMIT } from "tls";
|
||||||
|
|
||||||
|
|
||||||
// Remember to rename these classes and interfaces!
|
// Remember to rename these classes and interfaces!
|
||||||
@@ -79,8 +80,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { markDownData, nowFile, tags } =
|
const { markDownData, nowFile, tags } =await this.getNowFileMarkdownContent(this.app);
|
||||||
await this.getNowFileMarkdownContent(this.app);
|
|
||||||
|
|
||||||
|
|
||||||
if (markDownData) {
|
if (markDownData) {
|
||||||
@@ -90,7 +90,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
|||||||
if(res.status === 200){
|
if(res.status === 200){
|
||||||
new Notice(`${langConfig["sync-success"]}${basename}`)
|
new Notice(`${langConfig["sync-success"]}${basename}`)
|
||||||
}else {
|
}else {
|
||||||
new Notice(`${langConfig["sync-fail"]}${basename}`, 3000)
|
new Notice(`${langConfig["sync-fail"]}${basename}`, 5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,8 +99,19 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
|||||||
const nowFile = app.workspace.getActiveFile();
|
const nowFile = app.workspace.getActiveFile();
|
||||||
const { allowTags } = this.settings;
|
const { allowTags } = this.settings;
|
||||||
let tags = []
|
let tags = []
|
||||||
if (app.metadataCache.getFileCache(nowFile).tags !== undefined && allowTags) {
|
let fileTags = app.metadataCache.getFileCache(nowFile)?.frontmatter?.tags;
|
||||||
tags = app.metadataCache.getFileCache(nowFile).frontmatter.tags;
|
console.log(nowFile, fileTags)
|
||||||
|
console.log(app.metadataCache.getFileCache(nowFile))
|
||||||
|
if(allowTags && !fileTags) {
|
||||||
|
new Notice(langConfig["set-tags-fail"]);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (app.metadataCache.getFileCache(nowFile).tags !== undefined && allowTags) {
|
||||||
|
tags = app.metadataCache.getFileCache(nowFile).frontmatter.tags;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
new Notice(langConfig["set-tags-fail"]);
|
||||||
}
|
}
|
||||||
if (nowFile) {
|
if (nowFile) {
|
||||||
const markDownData = await nowFile.vault.read(nowFile);
|
const markDownData = await nowFile.vault.read(nowFile);
|
||||||
@@ -156,7 +167,7 @@ class SampleSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.notionAPI = value;
|
this.plugin.settings.notionAPI = value;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
t.inputEl.type = 'password'
|
// t.inputEl.type = 'password'
|
||||||
return t
|
return t
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -172,13 +183,13 @@ class SampleSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.databaseID = value;
|
this.plugin.settings.databaseID = value;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
t.inputEl.type = 'password'
|
// t.inputEl.type = 'password'
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
notionDatabaseID.controlEl.querySelector('input').type='password'
|
// notionDatabaseID.controlEl.querySelector('input').type='password'
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName("Banner url(optional)")
|
.setName("Banner url(optional)")
|
||||||
|
|||||||
Reference in New Issue
Block a user