Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当前文章评论数调用 #46

Open
lmm214 opened this issue Dec 6, 2020 · 5 comments
Open

当前文章评论数调用 #46

lmm214 opened this issue Dec 6, 2020 · 5 comments
Labels
enhancement New feature or request long-term This issue will not be done in the short term

Comments

@lmm214
Copy link

lmm214 commented Dec 6, 2020

希望增加「文章评论数」调用html,如当前文章访客数 <span id="twikoo_visitors">0</span> 一样。

另外,可以脑洞打开,当年Wordpress标配的:最新最热随机等文章(显示标题、阅读数、评论数),最热最新随机评论等

@heson525
Copy link

heson525 commented Dec 6, 2020

这个就厉害了😹

@imaegoo imaegoo added enhancement New feature or request long-term This issue will not be done in the short term labels Dec 7, 2020
@wztlink1013
Copy link

可否写一个调用 文章访问量/评论数 的API,类似最新评论一样

我觉得这里面不好权衡的就是,文章一多(比如500篇)就会对云数据库Counter集合查询带来压力、免费资源耗费多,但是感觉云函数处理性能,貌似也可以接受?

@imaegoo

@imaegoo
Copy link
Member

imaegoo commented Mar 31, 2021

可否写一个调用 文章访问量/评论数 的API,类似最新评论一样

@wztlink1013

  1. 文章访问量 API,还没有
  2. 文章评论数 API,已经有了:https://twikoo.js.org/api.html#get-comments-count
  3. API 是批量获取,不会消耗大量免费资源的
  4. 文章多了可以分页获取,不要一次获取 500 个数据,因为云开发数据库一次只能获取100条

@wztlink1013
Copy link

wztlink1013 commented Mar 31, 2021

可否写一个调用 文章访问量/评论数 的API,类似最新评论一样

@wztlink1013

  1. 文章访问量 API,还没有
  2. 文章评论数 API,已经有了:https://twikoo.js.org/api.html#get-comments-count
  3. API 是批量获取,不会消耗大量免费资源的
  4. 文章多了可以分页获取,不要一次获取 500 个数据,因为云开发数据库一次只能获取100条

那有什么方法可以批量获取各文章的访问量吗?
将资源文件夹下的所有文章url存到一个数组,然后再对其进行循环获取各个文章下的twikoo_visitors访问量?

https://7.dusays.com/2021/03/31/c9325daf53ffe.png【截图】

@imaegoo
Copy link
Member

imaegoo commented Mar 31, 2021

那有什么方法可以批量获取各文章的访问量吗?
将资源文件夹下的所有文章url存到一个数组,然后再对其进行循环获取各个文章下的twikoo_visitors访问量?

https://7.dusays.com/2021/03/31/c9325daf53ffe.png【截图】

@wztlink1013 需要写一个新的 API 来获取文章的访问量。但是很抱歉,工作原因,最近没有时间维护 twikoo,你可以参照获取评论数的接口代码,开发一个获取访问量的接口。

https://github.com/imaegoo/twikoo/blob/cabb841d614857c4f30fecfb5cae09e5808b0796/src/function/twikoo/index.js#L1265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request long-term This issue will not be done in the short term
Projects
None yet
Development

No branches or pull requests

4 participants