Closed tmirun closed 3 years ago
const Post = hexo.model('Post'); //This will give you access to posts
let allPosts = Post.toArray(); //All posts
allPosts[ x ].published? // false means the post is draft, true means the post is published.
@DeepSpaceHarbor thank guy, it is working, I can continue to work!
I will keep it open because I think we need to add it in hexo.locals.get('posts').
and this "hexo.model()" we should writing in API doc @SukkaW ?
these days I think we can use directlly https://github.com/hexojs/warehouse. to get informations. without hexo.locals.get('Post')
This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Check List
Please check followings before submitting a new issue.
hexo version
to check)Question
how can I get drafts? when I executed
hexo list post
it shows Draft like follow terminal log:but when I use hexo API
hexo.locals.toObject()
, it doesn't show drafts. the following console log shows 2 posts, drafts are not includedalso, I tried with
hexo.locals.get('posts')
but drafts is also not included.So I want to ask how can I get the drafts?
Thank to help me with this Question 😉