-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Site variables documentation is wrong #1567
Comments
So same as in #3038 how do I manage the returned (query) object? Because the answer in #3038 is to call each po in page.posts.data
p
time(datetime=date_xml(po.date) itemprop="datePublished")
= date(po.date)
span
= ' | ' + po.title The docs say each po in page.posts
p = po.title So ok The thing is I'm not a JS expert, I wanted to build a theme I referred to the doc, and when reading the actual doc I expect this code to work and actually it doesn't. each po in page.posts
p = po.title I wasn't aware of this warehouse doc (https://hexojs.github.io/warehouse/) by reading this I understand that the easiest solution for my issue is: each po in page.posts.toArray()
p
time(datetime=date_xml(po.date) itemprop="datePublished")
= date(po.date)
span
= ' | ' + po.title Is this the right way to do? I don't need to call an enumerator function like map or each since I'm already using each pug iterator that will work fine with an array. I'll PR the doc to fix it. |
|
IDK I saw toArray listed on the warehouse and I need an array in the end, sort return a query object for example. I ended up with something like that |
This part of the documentation in https://hexo.io/docs/variables#Site-Variables page is wrong :
See this related issue hexojs/hexo#3038
Actually
site.posts
orsite.pages
are not arrays returning posts or pages, you actually have to callsite.posts.data
orsite.pages.data
. I took me days to figure that out, I had the exact same problem as hexojs/hexo#3038The text was updated successfully, but these errors were encountered: