Skip to content

Commit

Permalink
fix: #744 WordPress更新文章标签重复
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Oct 8, 2023
1 parent dd65614 commit 1fc2171
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@
"vue-i18n": "^9.5.0",
"vue-router": "^4.2.5",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.44.3",
"zhi-blog-api": "^1.45.0",
"zhi-common": "^1.24.0",
"zhi-device": "^2.3.1",
"zhi-fetch-middleware": "^0.6.5",
"zhi-github-middleware": "^0.4.3",
"zhi-gitlab-middleware": "^0.6.5",
"zhi-lib-base": "^0.5.0",
"zhi-notion-markdown": "^0.1.4",
"zhi-siyuan-api": "^2.10.3",
"zhi-siyuan-api": "^2.10.5",
"zhi-xmlrpc-middleware": "^0.5.12"
}
}
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

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

16 changes: 12 additions & 4 deletions src/composables/usePublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,21 @@ const usePublish = () => {
const postKeywords = post?.mt_keywords?.split(",") ?? []
const newPostKeywords = newPost?.mt_keywords?.split(",") ?? []
// 合并并去重关键词
const mergedKeywords = [...new Set([...postKeywords, ...newPostKeywords])].filter((tag) => tag.trim() !== "")
const mergedKeywords = [
...new Set([
...postKeywords.map((tag) => tag.trim()),
...newPostKeywords.map((tag) => tag.trim()),
]),
].filter((tag) => tag.trim() !== "")
mergedPost.mt_keywords = mergedKeywords.join(",")

// 合并并去重分类
const mergedCategories = [...new Set([...(post?.categories ?? []), ...(newPost?.categories ?? [])])].filter(
(cate) => cate.trim() !== ""
)
const mergedCategories = [
...new Set([
...(post?.categories ?? []).map((cate) => cate.trim()),
...(newPost?.categories ?? []).map((cate) => cate.trim()),
]),
].filter((cate) => cate.trim() !== "")
mergedPost.categories = mergedCategories

return mergedPost
Expand Down

0 comments on commit 1fc2171

Please sign in to comment.