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

Q: Get recent posts #459

Closed
jjude opened this issue Jan 21, 2014 · 5 comments
Closed

Q: Get recent posts #459

jjude opened this issue Jan 21, 2014 · 5 comments
Labels
question Needs help in usage

Comments

@jjude
Copy link

jjude commented Jan 21, 2014

Is it possible to get recent 5 or 10 posts from a page (say /about) as like <%recent_posts(10)%> ? I have searched through the document and couldn't find an answer.

thank you,
Joseph

@chenall
Copy link
Contributor

chenall commented Jan 21, 2014

That's a good idea to write a helper plugin

@tommy351
Copy link
Member

You can take a look at the default theme:
https://github.com/hexojs/hexo-theme-landscape/blob/master/layout/_widget/recent_posts.ejs

However, I think it would be great to have a helper plugin.

@floriancargoet
Copy link
Contributor

I thought it would be great too, so I made one: https://npmjs.org/package/hexo-helper-recent_posts

In your theme : <%- recent_posts({ count: 10}) %>

Default options :

{
    count: 5,
    ulClass: 'recent_posts',
    liClass: 'recent_post'
}

@jjude
Copy link
Author

jjude commented Jan 22, 2014

Thank you @floriancargoet . Is there a way to use this in a page like About?

@chenall
Copy link
Contributor

chenall commented Jan 23, 2014

In hexo-theme-chenall, this feature is implemented.
install hexo-helper-recent_posts first and then use in posts.

{% ijs%} 
return recent_posts (); 
{% endijs%}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Needs help in usage
Projects
None yet
Development

No branches or pull requests

4 participants