tea3 / hexo-related-popular-posts

A hexo plugin that generates a list of links to related posts and popular posts. Also , this plugin can get Visitor Counts (PV) on posts.
MIT License
109 stars 14 forks source link

If there is no posts, the function should return empty #9

Closed huyingjie closed 6 years ago

huyingjie commented 6 years ago

I want to hide the text "Related Posts" if no posts are returned.

When there is no posts matched, popular_posts( {} , page ) returns

<ul class="popular-posts"><li class="popular-posts-item"><div class="popular-posts-title"><h3><a href="/untitled/" title="" rel="bookmark"></a></h3></div></li></ul>

It makes me impossible to write if statement to judge whether there exists at least related post or not.

I think popular_posts( {} , page ) should return empty string or any value equivalent to empty if no posts are related to the current post.

tea3 commented 6 years ago

@huyingjie Actually, this plugin have a more complicated problem. Sorry , I'll fix this problem someday . Please wait until update this plugin.

This problem can be temporarily avoided with the hexo clean command. And if you use cache , please delete cache file.

Also, you can judge freely in custom html. Please use popular_posts_json() tag.

huyingjie commented 6 years ago

@tea3 hexo clean does not work.

tea3 commented 6 years ago

@huyingjie I see . Which theme do you use ?

Also, could you avoid this issue temporarily with the popular_posts_json() tag ? This tag makes me possible to judge whether there exists posts .

huyingjie commented 6 years ago

https://github.com/huyingjie/hexo-theme-A-RSnippet

tea3 commented 6 years ago

@huyingjie Have you confirmed that the same problem will occur with default theme ?