mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 16:35:57 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
407688c303 | ||
|
|
84b998aa93 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "share-to-notionnext",
|
"id": "share-to-notionnext",
|
||||||
"name": "Share to NotionNext",
|
"name": "Share to NotionNext",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"minAppVersion": "0.0.1",
|
"minAppVersion": "0.0.1",
|
||||||
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
||||||
"author": "EasyChris, jxpeng98",
|
"author": "EasyChris, jxpeng98",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "share-to-notionnext",
|
"name": "share-to-notionnext",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
|
|||||||
@@ -1,23 +1,29 @@
|
|||||||
export const NoticeMsg: {[key: string]:any} = {
|
export const NoticeMsg: { [key: string]: any } = {
|
||||||
"en": {
|
"en": {
|
||||||
"notion-logo": "Share to NotionNext",
|
"notion-logo": "Share to NotionNext",
|
||||||
"sync-success": "Sync to NotionNext success: \n",
|
"sync-success": "Sync to NotionNext success: \n",
|
||||||
"sync-fail": "Sync to NotionNext fail: \n",
|
"sync-fail": "Sync to NotionNext fail: \n",
|
||||||
"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.",
|
"set-tags-fail": "Set tags fail,please check the frontmatter of the file or close the tag switch in the settings tab.",
|
||||||
},
|
"NNonMissing": "The 'NNon' property is missing in the settings. Please set it up.",
|
||||||
"zh": {
|
"set-api-id": "Please set up the notion API and database ID in the settings tab."
|
||||||
"notion-logo": "分享到NotionNext",
|
},
|
||||||
"sync-success": "同步到NotionNext成功:\n",
|
"zh": {
|
||||||
"sync-fail": "同步到NotionNext失败: \n",
|
"notion-logo": "分享到NotionNext",
|
||||||
"open-file": "请打开需要同步的文件",
|
"sync-success": "同步到NotionNext成功:\n",
|
||||||
"set-tags-fail": "设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
"sync-fail": "同步到NotionNext失败: \n",
|
||||||
},
|
"open-file": "请打开需要同步的文件",
|
||||||
|
"config-secrets-notion-api": "请在插件设置中添加notion API",
|
||||||
|
"config-secrets-database-id": "请在插件设置中添加database id",
|
||||||
|
"set-tags-fail": "设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
||||||
|
"NNonMissing": "未设置'NNon'属性,请在插件设置中选择NotionNext数据库。",
|
||||||
|
"set-api-id": "请在插件设置中设置notion API和database ID"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const NoticeMConfig = (lang:any) :any => {
|
export const NoticeMConfig = (lang: any): any => {
|
||||||
return NoticeMsg[lang]
|
return NoticeMsg[lang]
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/i18n.ts
Normal file
28
src/i18n.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
export const i18n: { [key: string]: any } = {
|
||||||
|
"en": {
|
||||||
|
NotionNextVersion: "NotionNext Version Database",
|
||||||
|
NotionNextVersionDesc: "Turn on this option if you are using NotionNext",
|
||||||
|
NotionNextSetting: "NotionNext Database Settings",
|
||||||
|
NotionAPI: "Notion API Token",
|
||||||
|
NotionAPIDesc: "It's a secret",
|
||||||
|
NotionID: "Database ID",
|
||||||
|
BannerUrl: "Banner url(optional)",
|
||||||
|
BannerUrlDesc: "page banner url(optional), default is empty, if you want to show a banner, please enter the url(like:https://raw.githubusercontent.com/EasyChris/obsidian-to-notion/ae7a9ac6cf427f3ca338a409ce6967ced9506f12/doc/2.png)",
|
||||||
|
NotionUser: "Notion ID(username, optional)",
|
||||||
|
NotionGeneralSetting: "General Notion Database Settings",
|
||||||
|
NotYetFinish: "Not finished. This function will be available in the next version",
|
||||||
|
},
|
||||||
|
"zh": {
|
||||||
|
NotionNextVersion: "NotionNext 版本数据库",
|
||||||
|
NotionNextVersionDesc: "如果你使用的是NotionNext,请打开此选项",
|
||||||
|
NotionNextSetting: "NotionNext 数据库参数设置",
|
||||||
|
NotionAPI: "Notion API 令牌",
|
||||||
|
NotionAPIDesc: "显示为密码",
|
||||||
|
NotionID: "数据库 ID",
|
||||||
|
BannerUrl: "封面图片地址(可选)",
|
||||||
|
BannerUrlDesc: "页面封面图片地址(可选),默认为空,如果你想显示封面图片,请输入图片地址(例如:https://raw.githubusercontent.com/EasyChris/obsidian-to-notion/ae7a9ac6cf427f3ca338a409ce6967ced9506f12/doc/2.png)",
|
||||||
|
NotionUser: "Notion ID(用户名,可选)",
|
||||||
|
NotionGeneralSetting: "普通 Notion 数据库设置",
|
||||||
|
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
||||||
|
},
|
||||||
|
}
|
||||||
25
src/main.ts
25
src/main.ts
@@ -19,7 +19,7 @@ interface PluginSettings {
|
|||||||
const langConfig = NoticeMConfig(window.localStorage.getItem('language') || 'en')
|
const langConfig = NoticeMConfig(window.localStorage.getItem('language') || 'en')
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: PluginSettings = {
|
const DEFAULT_SETTINGS: PluginSettings = {
|
||||||
NNon: true,
|
NNon: undefined,
|
||||||
notionAPI: "",
|
notionAPI: "",
|
||||||
databaseID: "",
|
databaseID: "",
|
||||||
bannerUrl: "",
|
bannerUrl: "",
|
||||||
@@ -65,13 +65,22 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async upload() {
|
async upload() {
|
||||||
const {NNon, notionAPI, databaseID} = this.settings;
|
const { notionAPI, databaseID, NNon} = this.settings;
|
||||||
|
|
||||||
|
// Check if NNon exists
|
||||||
|
if (NNon === undefined) {
|
||||||
|
const NNonmessage = NoticeMConfig(window.localStorage.getItem('language') || 'en')["NNonMissing"];
|
||||||
|
new Notice(NNonmessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the user has set up the Notion API and database ID
|
||||||
if (notionAPI === "" || databaseID === "") {
|
if (notionAPI === "" || databaseID === "") {
|
||||||
new Notice(
|
const setAPIMessage = NoticeMConfig(window.localStorage.getItem('language') || 'en')["set-api-id"];
|
||||||
"Please set up the notion API and database ID in the settings tab."
|
new Notice(setAPIMessage);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {markDownData, nowFile, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime} = await this.getNowFileMarkdownContent(this.app);
|
const {markDownData, nowFile, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime} = await this.getNowFileMarkdownContent(this.app);
|
||||||
|
|
||||||
|
|
||||||
@@ -178,7 +187,7 @@ class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
containerEl.empty();
|
containerEl.empty();
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName("NotionNext version")
|
.setName("NotionNext version ")
|
||||||
.setDesc("Turn on this option if you are using NotionNext")
|
.setDesc("Turn on this option if you are using NotionNext")
|
||||||
.addToggle((toggle) =>
|
.addToggle((toggle) =>
|
||||||
toggle
|
toggle
|
||||||
@@ -254,9 +263,7 @@ class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
containerEl.createEl('h2', {text: 'General Notion Database Settings'});
|
containerEl.createEl('h2', {text: 'General Notion Database Settings'});
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName("Not finished")
|
.setName("Not finished. This function will be available in the next version")
|
||||||
.setDesc("This functio will be available in the next version");
|
|
||||||
|
|
||||||
|
|
||||||
// new Setting(containerEl)
|
// new Setting(containerEl)
|
||||||
// .setName("Convert tags(optional)")
|
// .setName("Convert tags(optional)")
|
||||||
|
|||||||
Reference in New Issue
Block a user