Skip to content

Commit

Permalink
feat: 支持文章分类-单选分类
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 18, 2023
1 parent 782f4fb commit 4ca3ecd
Show file tree
Hide file tree
Showing 17 changed files with 531 additions and 107 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@terwer/eslint-config-custom": "^1.3.6",
"@types/crypto-js": "^4.1.1",
"@types/node": "^18.17.5",
"@vitejs/plugin-vue": "^4.2.3",
"@vitest/coverage-v8": "^0.34.1",
"@vitejs/plugin-vue": "^4.3.1",
"@vitest/coverage-v8": "^0.34.2",
"@vue/test-utils": "^2.4.1",
"esbuild-plugin-copy": "^2.1.1",
"esbuild-style-plugin": "^1.6.2",
Expand All @@ -44,11 +44,11 @@
"typescript": "^5.1.6",
"unplugin-auto-import": "^0.16.6",
"unplugin-vue-components": "^0.25.1",
"vercel": "^31.3.1",
"vercel": "^31.4.0",
"vite": "^4.4.9",
"vite-plugin-html": "^3.2.0",
"vite-plugin-node-polyfills": "^0.11.1",
"vitest": "^0.34.1",
"vite-plugin-node-polyfills": "^0.11.2",
"vitest": "^0.34.2",
"vue-tsc": "^1.8.8"
},
"dependencies": {
Expand Down Expand Up @@ -77,7 +77,7 @@
"zhi-github-middleware": "^0.2.9",
"zhi-lib-base": "^0.4.4",
"zhi-notion-markdown": "^0.1.4",
"zhi-siyuan-api": "^2.2.3",
"zhi-siyuan-api": "^2.3.0",
"zhi-xmlrpc-middleware": "^0.4.23"
}
}
128 changes: 64 additions & 64 deletions pnpm-lock.yaml

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

11 changes: 11 additions & 0 deletions src/adaptors/api/notion/notionApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ class NotionApiAdaptor extends BaseBlogApi {
const titles = notionPage?.properties?.title?.title ?? []
commonPost.title = titles.map((x: any) => x.plain_text).join("")
commonPost.description = "暂不支持Notion正文"

// const book = yuqueDoc.book
// const cats = []
// const catSlugs = []
//
// cats.push(book.name)
// commonPost.categories = cats
//
// catSlugs.push(book.namespace)
// commonPost.cate_slugs = catSlugs

return commonPost
}

Expand Down
6 changes: 6 additions & 0 deletions src/adaptors/api/yuque/useYuqueApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
import { YuqueApiAdaptor } from "~/src/adaptors/api/yuque/yuqueApiAdaptor.ts"
import { CategoryTypeEnum } from "zhi-blog-api"

const useYuqueApi = async (key: string, newCfg?: YuqueConfig) => {
// 创建应用日志记录器
Expand Down Expand Up @@ -73,6 +74,11 @@ const useYuqueApi = async (key: string, newCfg?: YuqueConfig) => {
}
}

// Yuque 使用单选分类
cfg.categoryType = CategoryTypeEnum.CategoryType_Single
// 启用知识库作为分类
cfg.enableKnowledgeSpace = true

// 创建 Yuque API 适配器
const blogApi = new YuqueApiAdaptor(appInstance, cfg)
logger.info("Yuque API created successfully.", cfg)
Expand Down
2 changes: 1 addition & 1 deletion src/adaptors/api/yuque/yuqueApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class YuqueApiAdaptor extends BaseBlogApi {
// 只获取文档库
if (repo.type === "Book") {
const cat = new CategoryInfo()
cat.categoryId = repo.slug
cat.categoryId = `${this.cfg.username}/${repo.slug}`
cat.categoryName = repo.name
cat.description = repo.name
cat.categoryDescription = repo.name
Expand Down
Loading

0 comments on commit 4ca3ecd

Please sign in to comment.