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

Created on 13 Feb 2014  ·  8Comments  ·  Source: hexojs/hexo

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!

question

Most helpful comment

Updated link for warehouse: https://github.com/hexojs/warehouse

All 8 comments

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?

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!

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

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

in the templates.

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

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

Cool. Thanks for explaining^^

if problem solved, please close it, thanks

Updated link for warehouse: https://github.com/hexojs/warehouse

Was this page helpful?
0 / 5 - 0 ratings