【问题标题】:How to get a Hexo-built site variables in a pug template?如何在 pug 模板中获取 Hexo 构建的站点变量?
【发布时间】:2018-02-21 10:27:18
【问题描述】:

我有一个 Pug 模板(将成为根 index.html),它应该只列出我的帖子的标题:

p first line of the page

ul
    each post in site.posts
        li= post.title

p last line of the page

在构建网站时,我进入index.html

<p>first line of the page</p>
<ul>
    <li></li>
    <li></li>
</ul>
<p>last line of the page</p>

我在这个网站上有两个帖子,两个 &lt;li&gt;&lt;/li&gt; 建议我迭代正确的变量(并且该变量是已知的)。

如何从数组site.posts 中获取这些元素的内容?

【问题讨论】:

    标签: pug templating hexo pugjs


    【解决方案1】:

    我相信这是a bug,下面的作品:

    p first line of the page
    
    ul
        each i in site.posts.data
            li= i.title
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-07
      • 1970-01-01
      • 1970-01-01
      • 2015-04-25
      • 1970-01-01
      • 2011-12-27
      相关资源
      最近更新 更多