mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-30 00:48:36 +08:00
add type and slug
This commit is contained in:
@@ -28,19 +28,19 @@ export class Upload2Notion {
|
||||
|
||||
// 因为需要解析notion的block进行对比,非常的麻烦,
|
||||
// 暂时就直接删除,新建一个page
|
||||
async updatePage(notionID:string, title:string, allowTags:boolean, tags:string[], childArr:any) {
|
||||
async updatePage(notionID:string, title:string, allowTags:boolean, tags:string[], type:string, slug:string, childArr:any) {
|
||||
await this.deletePage(notionID)
|
||||
const res = await this.createPage(title, allowTags, tags, childArr)
|
||||
const res = await this.createPage(title, allowTags, tags, type, slug, childArr)
|
||||
return res
|
||||
}
|
||||
|
||||
async createPage(title:string, allowTags:boolean, tags:string[], childArr: any) {
|
||||
async createPage(title:string, allowTags:boolean, tags:string[], type:string, slug:string, childArr: any) {
|
||||
const bodyString:any = {
|
||||
parent: {
|
||||
database_id: this.app.settings.databaseID
|
||||
},
|
||||
properties: {
|
||||
Name: {
|
||||
title: {
|
||||
title: [
|
||||
{
|
||||
text: {
|
||||
@@ -49,11 +49,25 @@ export class Upload2Notion {
|
||||
},
|
||||
],
|
||||
},
|
||||
Tags: {
|
||||
tags: {
|
||||
multi_select: allowTags && tags !== undefined ? tags.map(tag => {
|
||||
return {"name": tag}
|
||||
}) : [],
|
||||
},
|
||||
type: {
|
||||
select: {
|
||||
name: type || 'Post'
|
||||
}
|
||||
},
|
||||
slug: {
|
||||
rich_text: [
|
||||
{
|
||||
text: {
|
||||
content: slug || 'slug-1'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
children: childArr,
|
||||
}
|
||||
@@ -85,7 +99,7 @@ export class Upload2Notion {
|
||||
}
|
||||
}
|
||||
|
||||
async syncMarkdownToNotion(title:string, allowTags:boolean, tags:string[], markdown: string, nowFile: TFile, app:App, settings:any): Promise<any> {
|
||||
async syncMarkdownToNotion(title:string, allowTags:boolean, tags:string[], type:string, slug:string, markdown: string, nowFile: TFile, app:App, settings:any): Promise<any> {
|
||||
let res:any
|
||||
const yamlObj:any = yamlFrontMatter.loadFront(markdown);
|
||||
const __content = yamlObj.__content
|
||||
@@ -94,9 +108,9 @@ export class Upload2Notion {
|
||||
const notionID = frontmasster ? frontmasster.notionID : null
|
||||
|
||||
if(notionID){
|
||||
res = await this.updatePage(notionID, title, allowTags, tags, file2Block);
|
||||
res = await this.updatePage(notionID, title, allowTags, tags, type, slug, file2Block);
|
||||
} else {
|
||||
res = await this.createPage(title, allowTags, tags, file2Block);
|
||||
res = await this.createPage(title, allowTags, tags, type, slug, file2Block);
|
||||
}
|
||||
if (res.status === 200) {
|
||||
await this.updateYamlInfo(markdown, nowFile, res, app, settings)
|
||||
|
||||
Reference in New Issue
Block a user