在 Eleventy posts.json 中将 "tags" 添加到前面内容时的预期行为是什么?
What's the expected behaviour when adding "tags" to the front matter in Eleventy posts.json?
据我了解,在特定 Eleventy 目录的配置文件中添加一个 tags="post"
,比如 "posts",将标签 "post" 添加到所有 posts 并自动创建 collections.post。这似乎对我不起作用,我错过了什么吗?我可以迭代 collections.post 的唯一方法是,如果我为每个 post 添加标签 post(在每个 post 前面),或者如果我在 . eleventy.js 喜欢
eleventyConfig.addCollection("post", (collection) => {
return collection.getFilteredByGlob("_posts/*.md");
});
谢谢。
我想这取决于你所说的 "configuration file of a specific Eleventy directory" 是什么意思。要为目录指定数据,请参阅此处 https://www.11ty.dev/docs/data-template-dir/ 的指南,然后滚动到目录数据文件。理论上,您可以在 posts 文件夹中添加一个名为 posts.11tydata.json 的 JSON 文件,并像这样设置它:
{
"tags":"post"
}
我很确定这有效 - 现在正在测试。 ;)
据我了解,在特定 Eleventy 目录的配置文件中添加一个 tags="post"
,比如 "posts",将标签 "post" 添加到所有 posts 并自动创建 collections.post。这似乎对我不起作用,我错过了什么吗?我可以迭代 collections.post 的唯一方法是,如果我为每个 post 添加标签 post(在每个 post 前面),或者如果我在 . eleventy.js 喜欢
eleventyConfig.addCollection("post", (collection) => {
return collection.getFilteredByGlob("_posts/*.md");
});
谢谢。
我想这取决于你所说的 "configuration file of a specific Eleventy directory" 是什么意思。要为目录指定数据,请参阅此处 https://www.11ty.dev/docs/data-template-dir/ 的指南,然后滚动到目录数据文件。理论上,您可以在 posts 文件夹中添加一个名为 posts.11tydata.json 的 JSON 文件,并像这样设置它:
{
"tags":"post"
}
我很确定这有效 - 现在正在测试。 ;)