我有一个用帕格模板语言写的博客文章列表。每个博客文章都有一个正面的标题。例如:
---
id: "achilles-turtle-metapost"
title: "The achilles & turtle metapost"
date: "2019-08-14"
img: "blue-liquid.png"
tags: ["Achilles & Turtle", "Philosophy"]
excerpt: "Who is this achilles and his calm friend the turtle? And what are they talking about every day?"
---
p Some very simple content of this blog post.
p Dummy second paragraph使用静态站点生成器十一解析模板。
博客-列表.帕格看起来是这样的。变量collections.all被十一个博客文章正确地填充了数据。
- for (var postIdx = 0; postIdx < collections.all.length; postIdx++)
include blog-list-item.pug我的问题是: blog-list-item.pug需要for循环中当前元素的数据。如何访问blog-list-item.pug部分中的数据?
我已经试过了,但不起作用。(这适用于朴素的帕格):
- for (var postIdx = 0; postIdx < collections.all.length; postIdx++)
- var post = collections.all[postIdx].data // this is a reference to the frontmatter data
include blog-list-item.pug 当使用朴素pug时,post变量在blog-list-item.pug中可用。帕格将JavaScript上下文传递给包含的模板。但不是在用十一号的时候。
我遗漏了什么?
https://stackoverflow.com/questions/66737351
复制相似问题