Skip to content

Commit

Permalink
feat: 新增 Notion 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 3, 2023
1 parent db02695 commit e97a7ab
Show file tree
Hide file tree
Showing 16 changed files with 371 additions and 65 deletions.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"dependencies": {
"@element-plus/icons-vue": "^2.1.0",
"@notionhq/client": "^2.2.10",
"@vueuse/components": "^10.3.0",
"@vueuse/core": "^10.3.0",
"cross-fetch": "^3.1.8",
Expand All @@ -60,13 +61,13 @@
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.4",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.20.3",
"zhi-common": "^1.11.6",
"zhi-blog-api": "^1.20.4",
"zhi-common": "^1.11.7",
"zhi-device": "^2.3.0",
"zhi-fetch-middleware": "^0.2.6",
"zhi-github-middleware": "^0.1.3",
"zhi-lib-base": "^0.4.2",
"zhi-siyuan-api": "^1.29.3",
"zhi-xmlrpc-middleware": "^0.4.1"
"zhi-fetch-middleware": "^0.2.7",
"zhi-github-middleware": "^0.1.4",
"zhi-lib-base": "^0.4.3",
"zhi-siyuan-api": "^1.29.4",
"zhi-xmlrpc-middleware": "^0.4.2"
}
}
114 changes: 61 additions & 53 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions src/adaptors/api/notion/adaptor/notionApiAdaptor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import { BlogApi, UserBlog } from "zhi-blog-api"
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { NotionConfig } from "~/src/adaptors/api/notion/config/notionConfig.ts"

/**
* Notion API 适配器
*/
class NotionApiAdaptor extends BlogApi {
private readonly logger
private readonly cfg

constructor(appInstance: any, cfg: NotionConfig) {
super()
this.logger = createAppLogger("notion-api-adaptor")
this.cfg = cfg
}

public async getUsersBlogs(): Promise<UserBlog[]> {
return []
}
}

export { NotionApiAdaptor }
43 changes: 43 additions & 0 deletions src/adaptors/api/notion/config/notionConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import { PageTypeEnum, PasswordType } from "zhi-blog-api"
import { CommonblogConfig } from "~/src/adaptors/api/base/commonblog/config/CommonblogConfig.ts"

/**
* Notion 配置
*/
class NotionConfig extends CommonblogConfig {
constructor(password: string, middlewareUrl?: string) {
super("https://www.notion.so/", "https://api.notion.com/v1", "", password, middlewareUrl)

this.tokenSettingUrl = "https://www.notion.so/my-integrations"
this.previewUrl = "/[postid]"
this.pageType = PageTypeEnum.Markdown
this.passwordType = PasswordType.PasswordType_Token
}
}

export { NotionConfig }
Loading

0 comments on commit e97a7ab

Please sign in to comment.