mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 16:35:57 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c3ec6881e | |||
|
|
a80155fafc | ||
| 3a814b8390 | |||
| bb522db9a2 | |||
| 201f72ae0e | |||
| be6f192dd8 | |||
| 4ce1019094 | |||
| 095c608511 | |||
| 2d8d7fb11a | |||
| 36725cb699 | |||
|
|
654e7e854d | ||
|
|
fa67f08512 | ||
|
|
7e42ef49a7 | ||
|
|
5a95aa0acc |
24
CHANGELOG.md
24
CHANGELOG.md
@@ -1,25 +1,7 @@
|
||||
## Fix
|
||||
- fixed the issue that you cannot have empty values in the front matter of the customised database.
|
||||
- 修复了自定义数据库的前置数据中不能有空值的问题。
|
||||
For example, you have the property `tag` in your customised database, and you do not want to sync `tag` to Notion. You can remove the `tag` from the front matter.
|
||||
- 例如,自定义数据库中有属性`tag`,但是你不想将`tag`同步到Notion。现在,你可以直接在frontmatter中删除`tag`。
|
||||
|
||||
- Fix a gif link in README.md
|
||||
|
||||
## Improvement
|
||||
**⚠️⚠️⚠️: The exist customised database should be recreated if you want to update to version 2.3.0. The new version has a new database structure, and the old database structure is not compatible with the new version to build the index properly.**
|
||||
## Features
|
||||
|
||||
### 自定义数据库用户
|
||||
**⚠️⚠️⚠️: 如果你想要更新到2.3.0版本,你需要重新创建自定义数据库。新版本有一个新的数据库结构,旧的数据库结构无法构建索引。**
|
||||
|
||||
- redesigned the way to create new customised database. The modal has been removed with a more straightforward layout.
|
||||
- 重新设计了自定义数据库的创建方式。已删除模态框,采用更直观的布局。
|
||||

|
||||
|
||||
|
||||
- improved the edit modal for customised database. The layout has been simplified and the form has been reorganized.
|
||||
- 改进了自定义数据库的编辑模态框。简化了布局,重新组织了表单。
|
||||

|
||||
|
||||
- improved the preview modal for customised database.
|
||||
- 改进了自定义数据库的预览模态框。
|
||||

|
||||
- Change the success notice colour to green
|
||||
|
||||
377
README.md
377
README.md
@@ -7,13 +7,22 @@
|
||||
|
||||
[//]: # ([](https://GitHub.com/jxpeng98/obsidian-to-NotionNext/releases/))
|
||||
|
||||
|
||||
[//]: # ([中文文档](README-zh.md))
|
||||
|
||||
**Now, support both NotionNext and General databases with customised properties.**
|
||||
|
||||
**现在支持NotionNext和普通Notion数据库,可自定义数据库列表。**
|
||||
|
||||
## Precautions
|
||||
|
||||
### For customised database users
|
||||
|
||||
**⚠️⚠️⚠️: The existing customised database should be recreated if you want to update to version 2.3.0. The new version has a new database structure, and the old database structure is not compatible with the new version to build the index properly.**
|
||||
|
||||
### 自定义数据库用户
|
||||
|
||||
**⚠️⚠️⚠️: 如果你想要更新到2.3.0版本,你需要重新创建自定义数据库。新版本有一个新的数据库结构,旧的数据库结构无法构建索引。**
|
||||
|
||||
## TODO List
|
||||
|
||||
- [x] ~~Modify the Edit function for the custom properties. 改进自定义属性的编辑功能~~
|
||||
@@ -22,77 +31,225 @@
|
||||
- [x] ~~Support preview for database details in plugin settings. 支持预览数据库详情~~
|
||||
- [x] ~~Support edit for database details in plugin settings. 支持编辑数据库详情~~
|
||||
|
||||
## Precautions
|
||||
### For customised database users
|
||||
**⚠️⚠️⚠️: The exist customised database should be recreated if you want to update to version 2.3.0. The new version has a new database structure, and the old database structure is not compatible with the new version to build the index properly.**
|
||||
|
||||
### 自定义数据库用户
|
||||
**⚠️⚠️⚠️: 如果你想要更新到2.3.0版本,你需要重新创建自定义数据库。新版本有一个新的数据库结构,旧的数据库结构无法构建索引。**
|
||||
|
||||
## How to use
|
||||
You need seven steps to use this plugin in your Obsidian.
|
||||
1. Create a database in your Notion workspace.
|
||||
Open Notion, clink the `+` button on the left side, and 'Add a page' -> select 'Table' -> 'New database'.
|
||||
2. On the right-top corner, click the 'Share' -> 'Publish' -> 'Publish' -> copy the database id from the URL.
|
||||
3. go to [Notion API](https://www.notion.com/my-integrations) to create a new integration, and copy the token.
|
||||
4. Go back to your created Notion database, click the right-top '...' -> connections -> connect to -> find the integration you created and connect it.
|
||||
5. Go to obsidian settings -> community plugins -> search 'NotionNext' -> install it.
|
||||
6. Create a database in the plugin settings, and fill in the database details and all properties you want to sync (**Note: the name of the properties is case-sensitive.**).
|
||||
- There are three type of database that you can use:
|
||||
- NotionNext: the database for the NotionNext template.(**All the properties are in lowercase**)
|
||||
- General: the database for the general Notion database (**Only have `title` and `tags` columns**)
|
||||
- Custom: the database for the custom properties (You can customise the properties you want to sync)
|
||||
7. Create a new note in Obsidian, and fill in the frontmatter with the properties you want to sync.
|
||||
|
||||
## 使用方法
|
||||
如果你想使用这个插件,你需要完成下边的七个步骤。
|
||||
1. 首先在你的Notion中创建一个数据库。
|
||||
2. 点击右上角的'分享' -> '发布' -> '发布' -> 然后复制URL中的数据库ID。(版本不同,可能id的形式也不同。只需要复制在?之前的纯数字部分应该就可以了)
|
||||
3. 去[Notion API](https://www.notion.com/my-integrations)创建一个新的API,然后复制token。
|
||||
4. 回到你创建的Notion数据库,点击右上角的'...' -> 连接 -> 连接到 -> 把你刚才创建的API绑定到你的数据库
|
||||
5. 回到Obsidian的设置 -> 社区插件 -> 搜索'NotionNext' -> 安装
|
||||
6. 在插件设置中创建一个数据库,然后填写数据库的详情和你想要同步的属性 (**注意:Notion会识别表头的大小写,一定要和notion中的表头保持大小写一致**)。
|
||||
- 你可以使用三种类型的数据库:
|
||||
- NotionNext: 用于NotionNext模板的数据库。(**默认全部小写**)
|
||||
- General: 用于普通的Notion数据库(**只有`title`和`tags`两个属性**)
|
||||
- Custom: 用于自定义属性的数据库(你可以自定义你想要同步的属性)
|
||||
7. 在Obsidian中创建一个新的笔记,然后在frontmatter中写入你想要的属性。
|
||||
If you want to use this plugin, you need to follow the following steps to set up the plugin. The steps can be divided into two parts: setting up the Notion API and setting up the plugin in Obsidian.
|
||||
|
||||
## Example
|
||||
```plain
|
||||
### 1. Setting up the Notion API
|
||||
|
||||
1). Go to [Notion API](https://www.notion.com/my-integrations) to create a new integration, and **copy the token**.
|
||||
|
||||

|
||||
|
||||
2). Create a database in your Notion workspace.
|
||||
|
||||
Open Notion, click top-left `Create` a new page` -> You can give a title for the page and press "/" Select 'Database - Full page'.
|
||||
|
||||

|
||||
|
||||
Rename the database properties to `title` and `tags`.
|
||||
**⚠️⚠️`title` is the title column! `tags` is lower case⚠️⚠️**
|
||||
|
||||

|
||||
|
||||
3). Add the Notion API integration.
|
||||
|
||||
Click the right-top '...' -> connections -> connect to -> find the integration you created and connect it.
|
||||
|
||||

|
||||
|
||||
4). Publish the database to the public.
|
||||
Click the 'Share' -> 'Publish' -> 'Publish' -> **copy the database id from the URL**.
|
||||
|
||||

|
||||
|
||||
### 2. Setting up the plugin in Obsidian
|
||||
|
||||
1). Go to Obsidian settings -> community plugins -> search 'NotionNext' -> install it.
|
||||

|
||||
|
||||
2). Open the plugin settings and create a new database.
|
||||
|
||||

|
||||
|
||||
### 3. Create a database
|
||||
|
||||
**You can create three types of databases:**
|
||||
|
||||
#### 1️⃣ General database
|
||||
|
||||
General database is the default database, which only has the `title` and `tags` columns. **⚠️⚠️`title` and `tags` are lowercase⚠️⚠️**
|
||||
|
||||

|
||||
|
||||
The general is as follows:
|
||||
|
||||
- Full Name: the full name that you would like to give to the database.
|
||||
- Abbreviate Name: the abbreviation that you would like to give to the database.
|
||||
- Notion tags sync: whether you want to sync the tags column to Notion.
|
||||
- Customise title property: whether you want to change the `title` to another name (e.g., `name`).
|
||||
- Notion API token: the token you copied from the Notion API page.
|
||||
- Notion Database ID: the database ID you copied from the Notion database URL. (e.g., only copy `7158cd3f70ce4f60afd9da5bdf74fd0c` between `site/` and `?`. `https://jxpeng.notion.site/7158cd3f70ce4f60afd9da5bdf74fd0c?v=380317ac5373sadasdas3c13e618f&pvs=4**`)
|
||||
|
||||
After setting, it should look like this:
|
||||
|
||||

|
||||
|
||||
Once you click `save`, the new database will be created in the plugin settings and display in the detabase list.
|
||||
|
||||

|
||||
|
||||
#### 2️⃣ NotionNext database
|
||||
|
||||
If you use [NotionNext](https://github.com/tangly1024/NotionNext) to set up your website, you can use the NotionNext database. (**All the properties are in lowercase, and you do not need to change the properties**)
|
||||
|
||||

|
||||
|
||||
Like the general database, you need to fill in the following information:
|
||||
|
||||
- Full Name: the full name that you would like to give to the database.
|
||||
- Abbreviate Name: the abbreviation that you would like to give to the database.
|
||||
- Notion API token: the token you copied from the Notion API page.
|
||||
- Notion Database ID: the database ID you copied from the Notion database URL.
|
||||
|
||||
#### 3️⃣ Custom database
|
||||
|
||||
The custom database is purely customised, and you can customise the properties you want to sync. (**All the properties are in lowercase, and you do not need to change the properties**)
|
||||
|
||||

|
||||
|
||||
The basic information is identical to the general database and NotionNext database. You need to fill in the following information:
|
||||
|
||||
- Full Name: the full name that you would like to give to the database.
|
||||
- Abbreviate Name: the abbreviation that you would like to give to the database.
|
||||
- Notion API token: the token you copied from the Notion API page.
|
||||
- Notion Database ID: the database ID you copied from the Notion database URL.
|
||||
|
||||
After adding the information, You can click `Add New Property` to add the properties you want to sync. There is no limit to the number of properties you can add.
|
||||
|
||||

|
||||
|
||||
**⚠️⚠️⚠️**: **`Title column` is the main property in the Notion database, which has the open button to open the underlying page.** You can select the type of all other properties. **⚠️⚠️⚠️**
|
||||
|
||||

|
||||
|
||||
According to the previously shown database, you can use `title` as the `Title column`, and `Tags` as the property 1.
|
||||
|
||||

|
||||
|
||||
**Until now, you have set up the plugin in Obsidian. You can start syncing your notes to Notion.**
|
||||
|
||||
### 4. Start syncing
|
||||
|
||||
Create a new note in Obsidian, and fill in the front matter with the properties you want to sync.
|
||||
|
||||
#### 1️⃣ note for general database
|
||||
|
||||
For example, we can create a test note with the following front matter:
|
||||
|
||||
``` markdown
|
||||
---
|
||||
# default value has been set.
|
||||
# for any unwanted value, you can delete it or set it to empty.
|
||||
# for example, if you donot want to set password, you can delete password: "1234" or set it to password: ""
|
||||
# 我已经在插件中设置了默认值,如果有不需要的选项,可以直接删除。
|
||||
# 例如你不需要密码选项,你可以将password: "1234"删除,或者将它设置为空。
|
||||
# !!!!!!!!!!!!
|
||||
# 现在阶段一定不要修改表头的名字, please do not change the name of the header in YAML front matter
|
||||
# !!!!!!!!!!!!
|
||||
titleicon: 📎 # emoji icon, default is 📜, 默认是📜
|
||||
date: 2023-07-23 # default is today, 默认是今天。 Format is YYYY-MM-DD, 格式是YYYY-MM-DD
|
||||
coverurl: https://img.jxpeng.dev/2023/08/843e27a210847f05a0f7cfb121fec100.jpg # default is empty, 默认是空
|
||||
type: Post # Post or Page, default is Post, 默认是Post
|
||||
slug: test # slug for url, default is empty, 默认是空
|
||||
status: Draft # Draft, Invisible, Published, default is Draft, 默认是Draft
|
||||
category: test # default is 'Obsidian', 默认是'Obsidian'
|
||||
summary: this is a summary for test post # default is empty, 默认是空
|
||||
icon: fa-solid fa-camera # you can ignore this, default is empty, 默认是空,可直接删除
|
||||
password: "1234" # if you donot want to set password, you can delete this line, default is empty, 默认是空,可直接删除
|
||||
# 现在必须开启tags选项,否则会报错
|
||||
tags:
|
||||
- test # tags for post
|
||||
- web # add more tags if you want
|
||||
title: test
|
||||
tags: [test, web]
|
||||
---
|
||||
|
||||
This is a test file.
|
||||
|
||||
```
|
||||
|
||||

|
||||
- Once you create the properties, you can preview the database details in the plugin settings.
|
||||

|
||||
After creating the note, you can click the `Share to NotionNext` button on the left sidebar to sync the note to Notion.
|
||||
|
||||

|
||||
|
||||
#### 2️⃣ note for NotionNext database
|
||||
|
||||
We use the following front matter for the NotionNext database:
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: test-notionnext
|
||||
titleicon: 📎
|
||||
date: 2023-07-23
|
||||
coverurl: https://img.jxpeng.dev/2023/08/843e27a210847f05a0f7cfb121fec100.jpg
|
||||
type: Post
|
||||
slug: test
|
||||
status: Draft
|
||||
category: test
|
||||
summary: this is a summary for test post
|
||||
icon: fa-solid fa-camera
|
||||
password: "1234"
|
||||
tags:
|
||||
- test
|
||||
- web
|
||||
NotionID-pengjiaxin: 8ba573de-8fdf-4681-b063-c39d26e7860e
|
||||
---
|
||||
|
||||
## Acknowledgement
|
||||
this is a test file
|
||||
```
|
||||
|
||||

|
||||
|
||||
#### 3️⃣ note for custom database
|
||||
|
||||
##### sync title and tags
|
||||
|
||||
Use the previously created general database and rename `title` to `Name` and `tags` to `Tags` in Notion.
|
||||
|
||||

|
||||
|
||||
The front matter for the custom database is as follows:
|
||||
|
||||
```markdown
|
||||
---
|
||||
Name: test-custom
|
||||
Tags:
|
||||
- test
|
||||
- web
|
||||
---
|
||||
|
||||
This is a test file.
|
||||
```
|
||||
|
||||

|
||||
|
||||
##### sync more properties
|
||||
|
||||
Add more property to the custom database. For example, we can add a `summary` and `date` property to the custom database.
|
||||
|
||||
1). Click `Edit` in the plugin settings.
|
||||

|
||||
2). Click `Add` and add the `summary` and `date` property.
|
||||
|
||||

|
||||
|
||||
3). After adding the properties, you can see the properties in the plugin settings.
|
||||

|
||||
4). Add the `summary` and `date` in Notion
|
||||
|
||||

|
||||
|
||||
5). Create a new note with the `summary` and `date` property.
|
||||
|
||||
```markdown
|
||||
---
|
||||
Name: test-custom-more
|
||||
Tags:
|
||||
- test
|
||||
- web
|
||||
summary: this is a summary for test custom
|
||||
date: 2022-05-03
|
||||
---
|
||||
|
||||
This is a test file.
|
||||
```
|
||||
|
||||
6). Sync the note to Notion.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## Acknowledgment
|
||||
|
||||
Thanks to the [original author](https://github.com/EasyChris/obsidian-to-notion) for developing such a useful plugin that can synchronize Obsidian to Notion. However, the original repository can only sync Name and Tag information. For those like me who use [NotionNext](https://github.com/tangly1024/NotionNext) to set up their website, this presents some limitations. Every time I import, I need to make a lot of modifications.
|
||||
|
||||
@@ -100,102 +257,6 @@ Thus, based on the [original author's work](https://github.com/EasyChris/obsidia
|
||||
|
||||
---
|
||||
|
||||
<details> <summary> Previous How to Use </summary>
|
||||
|
||||
### Precautions
|
||||
|
||||
For now, this plugin is exclusively for [NotionNext](https://github.com/tangly1024/NotionNext). If you're not using this template, you'll keep receiving `error 400`.
|
||||
|
||||
For those without a NotionNext requirement, please use the original [Obsidian-to-notion](https://github.com/EasyChris/obsidian-to-notion).
|
||||
|
||||
### Pre-Installation Steps
|
||||
|
||||
Before installing the plugin, you must have set up the following:
|
||||
|
||||
1. Your NotionNext database.
|
||||
2. According to the original author's readme.md, set up the Notion API, and it should already be associated with your NotionNext repository.
|
||||
3. NotionNext Database ID
|
||||
4. Your NotionNext database should have the following contents:
|
||||
- type
|
||||
- title
|
||||
- slug
|
||||
- category
|
||||
- tags
|
||||
- date
|
||||
- status
|
||||
- summary
|
||||
- password
|
||||
- icon
|
||||
|
||||
From version 0.0.6, I also add the following contents:
|
||||
- titleicon: the unique icon for each post, it can only support emoji currently.
|
||||
- cover url: the cover image for each post, it should be end with a type of image, such as .jpg, .png, .gif, etc.
|
||||
|
||||
**If you've directly copied the NotionNext template, these contents should already exist. I've made changes to this plugin based on the original author's work. All you need to ensure is that your database has the above content, and every letter is in lowercase!!!**
|
||||
|
||||
**⚠️⚠️⚠️: All headers are in lowercase!!! The order doesn't matter!**
|
||||
|
||||
### Plugin Installation
|
||||
|
||||
#### Install via Community Plugins
|
||||
|
||||
Open `Obsidian settings -> Community Plugins -> Browse -> NotionNext -> Share to NotionNext`
|
||||
|
||||
#### Mannually Install
|
||||
|
||||
1. Close Obsidian.
|
||||
2. Download the plugin file from Release and unzip it into your Obsidian plugin directory.
|
||||
3. Re-open Obsidian, go to settings, and enable the plugin.
|
||||
4. In the settings, find Obsidian to NotionNext, and enter your NotionNext Database ID and API token.
|
||||
|
||||
### How to Use
|
||||
|
||||
### Using the Plugin
|
||||
|
||||
In the repository, I have uploaded a template which you can directly copy into your template folder. After that, use Obsidian's template feature to create a new note with one click.
|
||||
|
||||
If you don't want to use the template, you can also directly create a new file in Obsidian and then copy the content below. Then save it.
|
||||
|
||||
```markdown
|
||||
---
|
||||
# default value has been set.
|
||||
# for any unwanted value, you can delete it or set it to empty.
|
||||
# for example, if you donot want to set password, you can delete password: "1234" or set it to password: ""
|
||||
# 我已经在插件中设置了默认值,如果有不需要的选项,可以直接删除。
|
||||
# 例如你不需要密码选项,你可以将password: "1234"删除,或者将它设置为空。
|
||||
# !!!!!!!!!!!!
|
||||
# 现在阶段一定不要修改表头的名字, please do not change the name of the header in YAML front matter
|
||||
# !!!!!!!!!!!!
|
||||
titleicon: 📎 # emoji icon, default is 📜, 默认是📜
|
||||
date: 2023-07-23 # default is today, 默认是今天。 Format is YYYY-MM-DD, 格式是YYYY-MM-DD
|
||||
coverurl: https://img.jxpeng.dev/2023/08/843e27a210847f05a0f7cfb121fec100.jpg # default is empty, 默认是空
|
||||
type: Post # Post or Page, default is Post, 默认是Post
|
||||
slug: test # slug for url, default is empty, 默认是空
|
||||
stats: Draft # Draft, Invisible, Published, default is Draft, 默认是Draft
|
||||
category: test # default is 'Obsidian', 默认是'Obsidian'
|
||||
summary: this is a summary for test post # default is empty, 默认是空
|
||||
icon: fa-solid fa-camera # you can ignore this, default is empty, 默认是空,可直接删除
|
||||
password: "1234" # if you donot want to set password, you can delete this line, default is empty, 默认是空,可直接删除
|
||||
# 现在必须开启tags选项,否则会报错
|
||||
tags:
|
||||
- test # tags for post
|
||||
- web # add more tags if you want
|
||||
---
|
||||
|
||||
Contents Below
|
||||
|
||||
```
|
||||
|
||||
Usage of the template is as follows:
|
||||

|
||||
|
||||
**Plugin preview is shown below**
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
<details> <summary> Original README.md </summary>
|
||||
|
||||
Many Thanks for the original author's work. I've only made some changes to the original author's work. If you find this plugin useful, please give the [original author](https://github.com/EasyChris/obsidian-to-notion) a star.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "share-to-notionnext",
|
||||
"name": "Share to NotionNext",
|
||||
"version": "2.3.0",
|
||||
"version": "2.3.3",
|
||||
"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.",
|
||||
"author": "EasyChris, jxpeng98",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "share-to-notionnext",
|
||||
"version": "2.3.0",
|
||||
"version": "2.3.3",
|
||||
"type": "module",
|
||||
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
||||
"main": "main.js",
|
||||
|
||||
@@ -27,11 +27,11 @@ export const en = {
|
||||
DatabaseIDText: "Enter your Database ID",
|
||||
BannerUrl: "Banner url (optional)",
|
||||
BannerUrlDesc:
|
||||
"Default is empty, if you want to show a banner, please enter the url (like: https://abc.com/b.png)",
|
||||
"Default is empty, if you want to show a banner, please enter the url (like: https://abc.com/b.png)",
|
||||
BannerUrlText: "Enter your banner url",
|
||||
NotionUser: "Notion ID (username, optional)",
|
||||
NotionUserDesc:
|
||||
"Collect from share link likes:https://username.notion.site. Your notion id is [username]",
|
||||
"Collect from share link likes:https://username.notion.site. Your notion id is [username]",
|
||||
NotionUserText: "Enter your notion ID",
|
||||
NotionLinkDisplay: "Notion Link Display",
|
||||
NotionLinkDisplayDesc: "Default is ON, if you want to hide the link in the front matter, please turn it off",
|
||||
@@ -48,23 +48,23 @@ export const en = {
|
||||
NotionCustomValues: "Customise values property",
|
||||
NotionCustomValuesDesc: "Modify the column name of the Notion database,one per line",
|
||||
NotionCustomValuesText: "Enter all properties that you want to sync",
|
||||
NotYetFinish:
|
||||
"Not finished. This function will be available in the next version",
|
||||
NotYetFinish: "Not finished. This function will be available in the next version",
|
||||
PlaceHolder: "Enter database Name",
|
||||
"notion-logo": "Share to NotionNext",
|
||||
"sync-success": "Sync to NotionNext success: \n",
|
||||
"sync-fail": "Sync to NotionNext fail: \n",
|
||||
"sync-preffix": "Sync to ",
|
||||
"sync-success": "success",
|
||||
"sync-fail": "failed",
|
||||
"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.",
|
||||
"Please set up the notion API in the settings tab.",
|
||||
"config-secrets-database-id":
|
||||
"Please set up the database id in the settings tab.",
|
||||
"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,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.",
|
||||
"The 'NNon' property is missing in the settings. Please set it up.",
|
||||
"set-api-id":
|
||||
"Please set up the notion API and database ID in the settings tab.",
|
||||
"Please set up the notion API and database ID in the settings tab.",
|
||||
NotionCustomSettingHeader: "Notion Custom Database Settings",
|
||||
NotionCustomButton: "Notion Customised command switch",
|
||||
NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette",
|
||||
@@ -75,4 +75,5 @@ export const en = {
|
||||
AddCustomProperty: "Add Custom Property",
|
||||
AddNewProperty: "Add New Property",
|
||||
AddNewPropertyDesc: "Add new property match with your notion database",
|
||||
CopyErrorMessage: "Auto copy failed, please copy it manually",
|
||||
}
|
||||
|
||||
@@ -67,4 +67,5 @@ export const ja = {
|
||||
AddCustomProperty: "カスタムプロパティを追加",
|
||||
AddNewProperty: "新しいプロパティを追加",
|
||||
AddNewPropertyDesc: "新しいプロパティを追加してください",
|
||||
CopyErrorMessage: "自動コピーに失敗しました",
|
||||
};
|
||||
|
||||
@@ -70,4 +70,5 @@ export const zh = {
|
||||
AddCustomProperty: "添加自定义属性",
|
||||
AddNewProperty: "添加新属性",
|
||||
AddNewPropertyDesc: "添加一个和Notion数据库匹配的新属性",
|
||||
CopyErrorMessage: "复制链接失败,请手动复制",
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ export class EditModal extends SettingModal {
|
||||
|
||||
propertyLine.addDropdown((dropdown) => {
|
||||
const options: Record<string, string> = {
|
||||
'text': 'Text',
|
||||
'rich_text': 'Text',
|
||||
'number': 'Number',
|
||||
'select': 'Select',
|
||||
'multi_select': 'Multi-Select',
|
||||
|
||||
@@ -151,7 +151,7 @@ export class PreviewModal extends Modal {
|
||||
propertyLine.addDropdown((dropdown) => {
|
||||
const options: Record<string, string> = {
|
||||
'title': 'Title',
|
||||
'text': 'Text',
|
||||
'rich_text': 'Text',
|
||||
'number': 'Number',
|
||||
'select': 'Select',
|
||||
'multi_select': 'Multi-Select',
|
||||
|
||||
@@ -239,7 +239,7 @@ export class SettingModal extends Modal {
|
||||
|
||||
propertyLine.addDropdown((dropdown) => {
|
||||
const options: Record<string, string> = {
|
||||
'text': 'Text',
|
||||
'rich_text': 'Text',
|
||||
'number': 'Number',
|
||||
'select': 'Select',
|
||||
'multi_select': 'Multi-Select',
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface PluginSettings {
|
||||
databaseIDNext: string;
|
||||
bannerUrl: string;
|
||||
notionUser: string;
|
||||
NotionLinkDisplay: boolean;
|
||||
proxy: string;
|
||||
GeneralButton: boolean;
|
||||
tagButton: boolean;
|
||||
@@ -47,6 +48,7 @@ export const DEFAULT_SETTINGS: PluginSettings = {
|
||||
databaseIDNext: "",
|
||||
bannerUrl: "",
|
||||
notionUser: "",
|
||||
NotionLinkDisplay: true,
|
||||
proxy: "",
|
||||
GeneralButton: true,
|
||||
tagButton: true,
|
||||
@@ -83,6 +85,9 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
|
||||
this.createSettingEl(containerEl, i18nConfig.NotionUser, i18nConfig.NotionUserDesc, 'text', i18nConfig.NotionUserText, this.plugin.settings.notionUser, 'notionUser')
|
||||
|
||||
this.createSettingEl(containerEl, i18nConfig.NotionLinkDisplay, i18nConfig.NotionLinkDisplayDesc, 'toggle', i18nConfig.NotionLinkDisplay, this.plugin.settings.NotionLinkDisplay, 'NotionLinkDisplay')
|
||||
|
||||
|
||||
// add new button
|
||||
new Setting(containerEl)
|
||||
.setName("Add New Database")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { App, Notice, TFile } from "obsidian";
|
||||
import ObsidianSyncNotionPlugin from "../main";
|
||||
import { DatabaseDetails } from "../ui/settingTabs";
|
||||
import { i18nConfig } from "src/lang/I18n";
|
||||
|
||||
export async function updateYamlInfo(
|
||||
yamlContent: string,
|
||||
@@ -12,7 +13,7 @@ export async function updateYamlInfo(
|
||||
) {
|
||||
let { url, id } = res.json
|
||||
// replace www to notionID
|
||||
const { notionUser } = plugin.settings;
|
||||
const { notionUser, NotionLinkDisplay } = plugin.settings;
|
||||
const { abName } = dbDetails
|
||||
const notionIDKey = `NotionID-${abName}`;
|
||||
const linkKey = `link-${abName}`;
|
||||
@@ -31,25 +32,13 @@ export async function updateYamlInfo(
|
||||
}
|
||||
// add new notionID and link
|
||||
yamlContent[notionIDKey] = id;
|
||||
yamlContent[linkKey] = url;
|
||||
(NotionLinkDisplay) ? yamlContent[linkKey] = url : null;
|
||||
});
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(url)
|
||||
} catch (error) {
|
||||
new Notice(`复制链接失败,请手动复制${error}`)
|
||||
console.log(error)
|
||||
new Notice(`${i18nConfig.CopyErrorMessage}`);
|
||||
}
|
||||
// const __content = yamlContent.__content;
|
||||
// delete yamlContent.__content
|
||||
// const yamlhead = yaml.stringify(yamlContent)
|
||||
// // if yamlhead hava last \n remove it
|
||||
// const yamlhead_remove_n = yamlhead.replace(/\n$/, '')
|
||||
// // if __content have start \n remove it
|
||||
// const __content_remove_n = __content.replace(/^\n/, '')
|
||||
// const content = '---\n' +yamlhead_remove_n +'\n---\n' + __content_remove_n;
|
||||
// try {
|
||||
// await nowFile.vault.modify(nowFile, content)
|
||||
// } catch (error) {
|
||||
// new Notice(`write file error ${error}`)
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -18,13 +18,6 @@ export async function uploadCommandNext(
|
||||
|
||||
const { notionAPI, databaseID } = dbDetails;
|
||||
|
||||
// Check if NNon exists
|
||||
// if (NNon === undefined) {
|
||||
// const NNonmessage = i18nConfig.NNonMissing;
|
||||
// new Notice(NNonmessage);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Check if the user has set up the Notion API and database ID
|
||||
if (notionAPI === "" || databaseID === "") {
|
||||
const setAPIMessage = i18nConfig["set-api-id"];
|
||||
@@ -54,7 +47,7 @@ export async function uploadCommandNext(
|
||||
const res = await upload.syncMarkdownToNotionNext(basename, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, markDownData, nowFile, this.app);
|
||||
|
||||
if (res.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-success"]}${basename}`);
|
||||
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
|
||||
} else {
|
||||
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
|
||||
}
|
||||
@@ -88,7 +81,7 @@ export async function uploadCommandGeneral(
|
||||
const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app);
|
||||
|
||||
if (res.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-success"]}${basename}`);
|
||||
new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green";
|
||||
} else {
|
||||
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
|
||||
}
|
||||
@@ -122,7 +115,7 @@ export async function uploadCommandCustom(
|
||||
const res = await upload.syncMarkdownToNotionCustom(cover, customValues, markDownData, nowFile, this.app);
|
||||
|
||||
if (res.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-success"]}${basename}`);
|
||||
new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green";
|
||||
} else {
|
||||
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
|
||||
app: App,
|
||||
): Promise<any> {
|
||||
const options = {
|
||||
strictImageUrls: true,
|
||||
notionLimits: {
|
||||
truncate: false,
|
||||
}
|
||||
@@ -123,7 +124,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
|
||||
} else {
|
||||
res = await this.createPage(cover, customValues, file2Block);
|
||||
}
|
||||
if (res.status === 200) {
|
||||
if (res && res.status === 200) {
|
||||
await updateYamlInfo(markdown, nowFile, res, app, this.plugin, this.dbDetails);
|
||||
} else {
|
||||
new Notice(`${res.text}`);
|
||||
@@ -228,7 +229,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
|
||||
}
|
||||
);
|
||||
|
||||
console.log(properties)
|
||||
// console.log(properties)
|
||||
|
||||
return {
|
||||
parent: {
|
||||
|
||||
Reference in New Issue
Block a user