mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 16:35:57 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55804e491a |
@@ -26,12 +26,36 @@ export class Upload2Notion {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getDataBase(databaseID:string){
|
||||||
|
const response = await requestUrl({
|
||||||
|
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ' + this.app.settings.notionAPI,
|
||||||
|
'Notion-Version': '2022-06-28',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Check if cover is present in the JSON response and then get the URL
|
||||||
|
if (response.json.cover && response.json.cover.external) {
|
||||||
|
return response.json.cover.external.url;
|
||||||
|
} else {
|
||||||
|
return null; // or some other default value, if you prefer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 因为需要解析notion的block进行对比,非常的麻烦,
|
// 因为需要解析notion的block进行对比,非常的麻烦,
|
||||||
// 暂时就直接删除,新建一个page
|
// 暂时就直接删除,新建一个page
|
||||||
async updatePage(notionID:string, title:string, allowTags:boolean, emoji:string, cover:string, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, paword:string, favicon:string, datetime:string, childArr:any) {
|
async updatePage(notionID:string, title:string, allowTags:boolean, emoji:string, cover:string, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, paword:string, favicon:string, datetime:string, childArr:any) {
|
||||||
await this.deletePage(notionID)
|
await this.deletePage(notionID)
|
||||||
const res = await this.createPage(title, allowTags, emoji,cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, childArr)
|
const databasecover = await this.getDataBase(this.app.settings.databaseID)
|
||||||
return res
|
|
||||||
|
if (cover == null) {
|
||||||
|
cover = databasecover
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await this.createPage(title, allowTags, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, childArr)
|
||||||
}
|
}
|
||||||
|
|
||||||
async createPage(title:string, allowTags:boolean, emoji:string, cover:string, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, pawrod:string, favicon:string, datetime:string, childArr: any) {
|
async createPage(title:string, allowTags:boolean, emoji:string, cover:string, tags:string[], type:string, slug:string, stats:string, category:string, summary:string, pawrod:string, favicon:string, datetime:string, childArr: any) {
|
||||||
@@ -42,11 +66,6 @@ export class Upload2Notion {
|
|||||||
icon: {
|
icon: {
|
||||||
emoji: emoji || '📜'
|
emoji: emoji || '📜'
|
||||||
},
|
},
|
||||||
cover: {
|
|
||||||
external: {
|
|
||||||
url: cover || ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
title: [
|
title: [
|
||||||
@@ -121,8 +140,16 @@ export class Upload2Notion {
|
|||||||
},
|
},
|
||||||
children: childArr,
|
children: childArr,
|
||||||
}
|
}
|
||||||
|
if (cover) {
|
||||||
|
bodyString.cover = {
|
||||||
|
type: "external",
|
||||||
|
external: {
|
||||||
|
url: cover
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(this.app.settings.bannerUrl) {
|
if (!bodyString.cover && this.app.settings.bannerUrl) {
|
||||||
bodyString.cover = {
|
bodyString.cover = {
|
||||||
type: "external",
|
type: "external",
|
||||||
external: {
|
external: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "share-to-notionnext",
|
"id": "share-to-notionnext",
|
||||||
"name": "Share to NotionNext",
|
"name": "Share to NotionNext",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"minAppVersion": "0.0.1",
|
"minAppVersion": "0.0.1",
|
||||||
"description": "This is a plugin for Obsidian. This plugin shares obsidian md file to notion with notion api for NotionNext web deploy.",
|
"description": "This is a plugin for Obsidian. This plugin shares obsidian md file to notion with notion api for NotionNext web deploy.",
|
||||||
"author": "jxpeng98",
|
"author": "jxpeng98",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "share-to-notionnext",
|
"name": "share-to-notionnext",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "This is a plugin for Obsidian. This plugin share obsidian md file to notion with notion api for NotionNext web deploy.",
|
"description": "This is a plugin for Obsidian. This plugin share obsidian md file to notion with notion api for NotionNext web deploy.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user