Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

How to select all posts in a certain tag or category and assign it to page.posts of the page I just created? #493

Closed
daisygao opened this Issue · 7 comments

3 participants

@daisygao

When I try to create a page "\Projects" to list all my posts with category "Projects" in an Archive-page style, I use the command "hexo n category Projects". However, when rendering the page using category.ejs, page.posts can't be recognized. I wonder if there's a way to let this page object be filled with all posts with category "Projects"?

Thanks!

@daisygao

I tried hexo n page "Projects" and set the category: Projects. The result is the same. page.posts equals null. How could I assign all the posts with category "Projects" to page.posts?

@daisygao

I know url /categories/Projects returns exactly what I want. I truly want to understand how to select all posts in a certain tag or category though. Thanks!

@tommy351
Owner

Though I don't understand why you want to do this. You can use

<% site.categories.findOne({name: 'projects'}) %>

in the templates.

@tommy351 tommy351 added the question label
@daisygao

Thanks! I'm not familiar with node.js grammer >3< This is mongoDB usage right?

@tommy351
Owner

No, Hexo uses Warehouse, a simple JSON database with MongoDB-like syntax.
http://zespia.tw/hexo/api/warehouse/classes/Database.html

@daisygao

Cool. Thanks for explaining^^

@Xuanwo
Collaborator

if problem solved, please close it, thanks

@tommy351 tommy351 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.