complete the code

This commit is contained in:
Jiaxin Peng
2023-08-09 20:41:32 +01:00
parent 0bd4427f7a
commit f4ab15c0d5
2 changed files with 17 additions and 10 deletions

View File

@@ -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, paword:string, favicon: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, datetime:string, childArr:any) {
await this.deletePage(notionID)
const res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, childArr)
const res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, datetime, childArr)
return res
}
async createPage(title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, pawrod:string, favicon: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, datetime:string, childArr: any) {
const bodyString:any = {
parent: {
database_id: this.app.settings.databaseID
@@ -104,6 +104,11 @@ export class Upload2Notion {
}
}
]
},
date: {
date: {
start: datetime || new Date().toISOString()
}
}
},
children: childArr,
@@ -136,7 +141,7 @@ export class Upload2Notion {
}
}
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<any> {
async syncMarkdownToNotion(title:string, allowTags:boolean, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, paword:string, favicon:string, datetime:string, markdown: string, nowFile: TFile, app:App, settings:any): Promise<any> {
let res:any
const yamlObj:any = yamlFrontMatter.loadFront(markdown);
const __content = yamlObj.__content
@@ -145,9 +150,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, paword, favicon, file2Block);
res = await this.updatePage(notionID, title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, datetime, file2Block);
} else {
res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, file2Block);
res = await this.createPage(title, allowTags, tags, type, slug, stats, category, summary, paword, favicon, datetime, file2Block);
}
if (res.status === 200) {
await this.updateYamlInfo(markdown, nowFile, res, app, settings)