Skip to content

Commit

Permalink
feat: 掘金平台支持分类与标签
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Sep 8, 2023
1 parent 975c234 commit 39d7b00
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 51 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ Publish articles from siyuan-note to platforms such as Yuque, Notion, Cnblogs, W

Support features such as fast publishing, image bed management, platform expansion, smart labels, etc.

> 🎉 The first version `1.13.0` of Publish Tool that supports WeChat Official Accounts released!
> 🎉 The first version `1.14.0` of Publish Tool that support Jianshu, Juejin and Hugo, Jekyll, Vuepress, Vuepress2, Vitepress is released!
> Platform Limitations:
- **WeChat Official Accounts**: Publishing Tool now supports posting articles to the WeChat Official Accounts draft box in version `1.13.0` and beyond. However, due to limitations on the WeChat platform in Electron, normal login operations are not possible. Therefore, you will need to visit `https://mp.weixin.qq.com/` yourself, complete the login, copy the cookie, and then paste it into the configuration options.
- **Notion**: Since Notion is block-based, not a whole document, it is constrained by technology and does not support updates. To update, you can only delete and then repost it.
- **Juejin**: Due to the mandatory requirements of the Jujin platform, tags and classifications must be filled in, if you do not select publishing, a backend classification and programmer label will be added by default, otherwise you will not be able to publish.

> [Click here](https://blog.terwer.space/s/20230810132040-nn4q7vs) to view the latest help documentation.
Expand All @@ -28,15 +29,27 @@ Names not listed in order
- [X] Notion
- [X] Github
- [X] Hexo
- [X] Hugo
- [X] Jekyll
- [X] Vuepress
- [X] Vuepress2
- [X] Vitepress
- [X] Gitlab
- [X] Gitlabhexo
- [X] Gitlabhugo
- [X] Gitlabjekyll
- [X] Gitlabvuepress
- [X] Gitlabvuepress2
- [X] Gitlabvitepress
- [X] Metaweblog
- [X] Cnblogs
- [X] Typecho
- [X] WordPress
- [X] Zhihu
- [X] CSDN
- [X] Wechat
- [X] Jianshu
- [X] Juejin

## Core Features

Expand Down Expand Up @@ -72,6 +85,12 @@ This plugin is fully compatible with `siyuan-note PC Client` , due to limited pe
- [X] Single-choice knowledge space
- [X] Tree-shaped radio knowledge space

- [X] tag
- [X] Multi-select tab

- [X] Label alias
- [X] Radio label alias

## Platform Adaptation Plan

If you have a platform you want to use, but this tool has not yet been implemented, you can submit
Expand Down
22 changes: 20 additions & 2 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

将思源笔记的文章发布到语雀、Notion、Cnblogs、WordPress、Typecho、Hexo、知乎 等平台,支持极速发布、图床管理、平台扩展、智能标签等特色功能。

> 🎉 发布工具首个支持微信公众号的版本 `1.13.0` 发布!
> 🎉 发布工具首个支持简书、掘金以及 Hugo、Jekyll、Vuepress、Vuepress2、Vitepress 的版本 `1.14.0` 发布!
> 平台限制说明
- 所有平台:发布工具每次都会获取思源笔记最新编辑的正文进行覆盖发布。每次发布都会覆盖正文,每次发布都会覆盖正文,每次发布都会覆盖正文。因此,请勿在平台自行修改正文。
- **微信公众号**:目前,发布工具在 `1.13.0+` 已经支持发布文章到微信公众号草稿箱。但是由于微信平台在 Electron 上有限制,无法正常进行登录操作。因此,只能自己访问 `https://mp.weixin.qq.com/` ,登录完成之后,复制cookie然后粘贴到配置选项。
- **Notion**: 由于Notion是基于块的,不是整篇文档,受限于技术,notion不支持更新。如需更新,目前只能删除后重新发布。

- **掘金**:由于掘金平台强制要求,必须填写标签和分类,如果发布不选择默认会加上一个后端分类、程序员标签,否则将无法发布。

**遇到问题或者需求建议?请加QQ群 `895063267` 讨论。或者查看下面的在线文档:**

Expand All @@ -31,15 +31,27 @@
- [X] Notion
- [X] Github
- [X] Hexo
- [X] Hugo
- [X] Jekyll
- [X] Vuepress
- [X] Vuepress2
- [X] Vitepress
- [X] Gitlab
- [X] Gitlabhexo
- [X] Gitlabhugo
- [X] Gitlabjekyll
- [X] Gitlabvuepress
- [X] Gitlabvuepress2
- [X] Gitlabvitepress
- [X] Metaweblog
- [X] 博客园
- [X] Typecho
- [X] WordPress
- [X] 知乎
- [X] CSDN
- [X] 微信公众号
- [X] 简书
- [X] 掘金

## 核心特色

Expand Down Expand Up @@ -75,6 +87,12 @@
- [X] 单选知识空间
- [X] 树形单选知识空间

- [X] 标签
- [X] 多选标签

- [X] 标签别名
- [X] 单选标签别名

## 平台适配计划

如果你有想使用的平台,但是此工具目前还没实现,可在这里提交 [思源笔记发布工具插件平台适配跟踪表](https://terwergreen.feishu.cn/share/base/form/shrcnGRdThUiqnhBg15xgclMM0c)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@
"vue-i18n": "^9.3.0",
"vue-router": "^4.2.4",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.36.3",
"zhi-blog-api": "^1.37.1",
"zhi-common": "^1.23.7",
"zhi-device": "^2.3.1",
"zhi-fetch-middleware": "^0.6.4",
"zhi-github-middleware": "^0.4.2",
"zhi-gitlab-middleware": "^0.6.4",
"zhi-lib-base": "^0.5.0",
"zhi-notion-markdown": "^0.1.4",
"zhi-siyuan-api": "^2.9.0",
"zhi-siyuan-api": "^2.9.2",
"zhi-xmlrpc-middleware": "^0.5.11"
}
}
74 changes: 38 additions & 36 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/adaptors/web/juejin/juejinConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class JuejinConfig extends CommonWebConfig {
this.passwordType = PasswordType.PasswordType_Cookie
this.usernameEnabled = false
this.tagEnabled = false
this.slugTagEnabled = true
this.tagSlugEnabled = true
this.cateEnabled = false
this.categoryType = CategoryTypeEnum.CategoryType_Single
this.knowledgeSpaceEnabled = true
Expand Down
22 changes: 19 additions & 3 deletions src/adaptors/web/juejin/juejinWebAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,27 @@ class JuejinWebAdaptor extends BaseWebApi {
}

public async addPost(post: Post) {
const cate_slug = post.cate_slugs?.[0] ?? this.cfg.blogid
let cate_slug = post.cate_slugs?.[0] ?? this.cfg.blogid
if (StrUtil.isEmptyString(cate_slug)) {
// 默认分类:后端
cate_slug = "6809637769959178254"
this.logger.error("掘金平台未选择分类,将使用默认分类:后端")
throw new Error("掘金平台必须选择一个分类")
}

let tag_slug = post.tags_slugs ?? ""
if (StrUtil.isEmptyString(tag_slug)) {
// 默认贴标签:程序员
tag_slug = "6809640482725954000"
this.logger.error("掘金平台未选择标签,将使用默认标签:程序员")
throw new Error("掘金平台必须选择一个标签")
}

// 保存草稿
const draftUrl = "https://api.juejin.cn/content_api/v1/article_draft/create"
const draftParams = {
category_id: cate_slug,
tag_ids: [],
tag_ids: tag_slug.split(","),
link_url: "",
cover_image: "",
title: post.title,
Expand Down Expand Up @@ -121,6 +132,11 @@ class JuejinWebAdaptor extends BaseWebApi {
throw new Error("掘金平台必须选择一个分类")
}

const tag_slug = post.tags_slugs ?? ""
if (StrUtil.isEmptyString(tag_slug)) {
throw new Error("掘金平台必须选择一个标签")
}

const juejinPostKey = this.getJuejinPostidKey(postid)
// const pageId = juejinPostKey.pageId
const draftId = juejinPostKey.draftId
Expand All @@ -130,7 +146,7 @@ class JuejinWebAdaptor extends BaseWebApi {
const draftParams = {
id: draftId,
category_id: cate_slug,
tag_ids: [],
tag_ids: tag_slug.split(","),
link_url: "",
cover_image: "",
title: post.title,
Expand Down

0 comments on commit 39d7b00

Please sign in to comment.