diff --git a/Upload2Notion.ts b/Upload2Notion.ts index d8ca8c7..07ed6eb 100644 --- a/Upload2Notion.ts +++ b/Upload2Notion.ts @@ -28,13 +28,13 @@ export class Upload2Notion { // 因为需要解析notion的block进行对比,非常的麻烦, // 暂时就直接删除,新建一个page - async updatePage(notionID:string, title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, childArr:any) { + async updatePage(notionID:string, title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, paword:string, favicon:string, childArr:any) { await this.deletePage(notionID) - const res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, childArr) + const res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, childArr) return res } - async createPage(title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, childArr: any) { + async createPage(title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, pawrod:string, favicon:string, childArr: any) { const bodyString:any = { parent: { database_id: this.app.settings.databaseID @@ -86,6 +86,24 @@ export class Upload2Notion { } } ] + }, + password: { + rich_text: [ + { + text: { + content: pawrod || '' + } + } + ] + }, + icon: { + rich_text: [ + { + text: { + content: favicon || '' + } + } + ] } }, children: childArr, @@ -118,7 +136,7 @@ export class Upload2Notion { } } - async syncMarkdownToNotion(title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, markdown: string, nowFile: TFile, app:App, settings:any): Promise { + async syncMarkdownToNotion(title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, paword:string, favicon:string, markdown: string, nowFile: TFile, app:App, settings:any): Promise { let res:any const yamlObj:any = yamlFrontMatter.loadFront(markdown); const __content = yamlObj.__content @@ -127,9 +145,9 @@ export class Upload2Notion { const notionID = frontmasster ? frontmasster.notionID : null if(notionID){ - res = await this.updatePage(notionID, title, allowTags, tags, type, slug, stats, category, summary, file2Block); + res = await this.updatePage(notionID, title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, file2Block); } else { - res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, file2Block); + res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, file2Block); } if (res.status === 200) { await this.updateYamlInfo(markdown, nowFile, res, app, settings) diff --git a/main.ts b/main.ts index e10bed8..304ee9a 100644 --- a/main.ts +++ b/main.ts @@ -80,13 +80,13 @@ export default class ObsidianSyncNotionPlugin extends Plugin { ); return; } - const { markDownData, nowFile, tags, type, slug, stats, category, summary } =await this.getNowFileMarkdownContent(this.app); + const { markDownData, nowFile, tags, type, slug, stats, category, summary,paword, favicon } =await this.getNowFileMarkdownContent(this.app); if (markDownData) { const { basename } = nowFile; const upload = new Upload2Notion(this); - const res = await upload.syncMarkdownToNotion(basename, allowTags, tags, type, slug, stats, category, summary, markDownData, nowFile, this.app, this.settings) + const res = await upload.syncMarkdownToNotion(basename, allowTags, tags, type, slug, stats, category, summary, paword, favicon, markDownData, nowFile, this.app, this.settings) if(res.status === 200){ new Notice(`${langConfig["sync-success"]}${basename}`) }else { @@ -104,6 +104,8 @@ export default class ObsidianSyncNotionPlugin extends Plugin { let stats = '' let category = '' let summary = '' + let paword = '' + let favicon = '' const FileCache = app.metadataCache.getFileCache(nowFile) try { @@ -114,6 +116,8 @@ export default class ObsidianSyncNotionPlugin extends Plugin { stats = FileCache.frontmatter.stats; category = FileCache.frontmatter.category; summary = FileCache.frontmatter.summary; + paword = FileCache.frontmatter.password; + favicon = FileCache.frontmatter.icon; } } catch (error) { new Notice(langConfig["set-tags-fail"]); @@ -129,6 +133,8 @@ export default class ObsidianSyncNotionPlugin extends Plugin { stats, category, summary, + paword, + favicon }; } else { new Notice(langConfig["open-file"]);