Skip to content

Commit

Permalink
feat: fix post list info
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Feb 27, 2024
1 parent c2d8c67 commit 8d37b6f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 6 additions & 0 deletions libs/zhi-siyuan-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# zhi-siyuan-api

## 2.15.0

### Minor Changes

- fix post list info

## 2.14.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-siyuan-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-siyuan-api",
"version": "2.14.5",
"version": "2.15.0",
"type": "module",
"description": "a siyuan-note api including both kernel and client",
"main": "./dist/index.js",
Expand Down
21 changes: 6 additions & 15 deletions libs/zhi-siyuan-api/src/lib/adaptor/siYuanApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,14 @@ class SiYuanApiAdaptor extends BlogApi {
}
const k = keyword ?? ""
const siyuanPosts = await this.siyuanKernelApi.getRootBlocks(pg, numOfPosts, k)
// logUtil.logInfo(siyuanPosts)

this.logger.debug("getRecentPosts from siyuan, get counts =>", siyuanPosts.length)
for (let i = 0; i < siyuanPosts.length; i++) {
const siyuanPost = siyuanPosts[i]
const post = await this.getPost(siyuanPost.root_id, false, true)

// 适配公共属性
const commonPost = new Post()
commonPost.postid = siyuanPost.root_id
commonPost.title = post.title
commonPost.description = post.description
commonPost.permalink = post.permalink
commonPost.isPublished = post.isPublished
commonPost.mt_keywords = post.mt_keywords
commonPost.categories = post.categories
result.push(commonPost)
if (siyuanPosts && siyuanPosts.length && siyuanPosts.length > 0) {
for (let i = 0; i < siyuanPosts.length; i++) {
const siyuanPost = siyuanPosts[i]
const post = await this.getPost(siyuanPost.root_id, false, true)
result.push(post)
}
}

return result
Expand Down

0 comments on commit 8d37b6f

Please sign in to comment.