Merge pull request #24 from jxpeng98/notion-link

feat: add notion link display
This commit is contained in:
Jiaxin Peng
2024-07-05 09:49:27 +01:00
committed by GitHub
3 changed files with 14 additions and 35 deletions

View File

@@ -1,25 +1,12 @@
## Fix ## Feature
- 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`
- add a notion link display button to control whether to display the synced notion link in the front matter of the markdown file.
- 增加 notion 链接显示按钮,控制是否在 markdown 文件的 front matter 中显示已经生成的 notion 文章链接。
## Improvement Setting tabs:
**⚠️⚠️⚠️: 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.**
### 自定义数据库用户 ![setting tab](https://minioapi.pjx.ac.cn/img1/2024/07/31b2e9844c184bc8fd461b2940c2397a.png)
**⚠️⚠️⚠️: 如果你想要更新到2.3.0版本,你需要重新创建自定义数据库。新版本有一个新的数据库结构,旧的数据库结构无法构建索引。**
- redesigned the way to create new customised database. The modal has been removed with a more straightforward layout. Front matter after sync:
- 重新设计了自定义数据库的创建方式。已删除模态框,采用更直观的布局。
![](https://minioapi.pjx.ac.cn/img1/2024/07/7a1550aefd71175c981077ce46d03c87.png)
![frontmatter](https://minioapi.pjx.ac.cn/img1/2024/07/d1bd58bf878abfb59dd67986bae99cc4.png)
- improved the edit modal for customised database. The layout has been simplified and the form has been reorganized.
- 改进了自定义数据库的编辑模态框。简化了布局,重新组织了表单。
![](https://minioapi.pjx.ac.cn/img1/2024/07/471ea519b7cb3fba8f0b57956bb1f973.png)
- improved the preview modal for customised database.
- 改进了自定义数据库的预览模态框。
![](https://minioapi.pjx.ac.cn/img1/2024/07/9599d77116afad065d2e31129942acc7.png)

View File

@@ -12,6 +12,7 @@ export interface PluginSettings {
databaseIDNext: string; databaseIDNext: string;
bannerUrl: string; bannerUrl: string;
notionUser: string; notionUser: string;
NotionLinkDisplay: boolean;
proxy: string; proxy: string;
GeneralButton: boolean; GeneralButton: boolean;
tagButton: boolean; tagButton: boolean;
@@ -47,6 +48,7 @@ export const DEFAULT_SETTINGS: PluginSettings = {
databaseIDNext: "", databaseIDNext: "",
bannerUrl: "", bannerUrl: "",
notionUser: "", notionUser: "",
NotionLinkDisplay: true,
proxy: "", proxy: "",
GeneralButton: true, GeneralButton: true,
tagButton: 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.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 // add new button
new Setting(containerEl) new Setting(containerEl)
.setName("Add New Database") .setName("Add New Database")

View File

@@ -12,7 +12,7 @@ export async function updateYamlInfo(
) { ) {
let { url, id } = res.json let { url, id } = res.json
// replace www to notionID // replace www to notionID
const { notionUser } = plugin.settings; const { notionUser, NotionLinkDisplay } = plugin.settings;
const { abName } = dbDetails const { abName } = dbDetails
const notionIDKey = `NotionID-${abName}`; const notionIDKey = `NotionID-${abName}`;
const linkKey = `link-${abName}`; const linkKey = `link-${abName}`;
@@ -31,7 +31,7 @@ export async function updateYamlInfo(
} }
// add new notionID and link // add new notionID and link
yamlContent[notionIDKey] = id; yamlContent[notionIDKey] = id;
yamlContent[linkKey] = url; (NotionLinkDisplay) ? yamlContent[linkKey] = url : null;
}); });
try { try {
@@ -39,17 +39,4 @@ export async function updateYamlInfo(
} catch (error) { } catch (error) {
new Notice(`复制链接失败,请手动复制${error}`) new Notice(`复制链接失败,请手动复制${error}`)
} }
// 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}`)
// }
} }