问题
I have a Pug template (for what will become the root index.html
) which is supposed to just list the titles of my posts:
p first line of the page
ul
each post in site.posts
li= post.title
p last line of the page
When building the site I get in index.html
<p>first line of the page</p>
<ul>
<li></li>
<li></li>
</ul>
<p>last line of the page</p>
I have two posts on this site and the two <li></li>
suggest that I iterate over the right variable (and that the variable is known).
How can I get the content of these elements from Array site.posts
?
回答1:
I believe this is a bug, the following works:
p first line of the page
ul
each i in site.posts.data
li= i.title
来源:https://stackoverflow.com/questions/48903549/how-to-get-a-hexo-built-site-variables-in-a-pug-template