How to get a Hexo-built site variables in a pug template?

扶醉桌前 提交于 2019-12-11 16:15:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!