如何在代码中创建高度收藏

发布于 2025-02-11 11:33:52 字数 237 浏览 1 评论 0原文

我想根据“标签”前材料以外的逻辑创建集合:

  • 我们使用FrontMatter用status来标记我们的文章。我想用它为所有不同状态提供收集。然后,我可以轻松地显示所有“评论中”的帖子。
  • 我们有年度审核政策,因此我希望每晚建造在此审核日期的一个月内拾取所有文章,并将其添加到另一个收藏中。

那么,是否有一种方法可以在110中编程创建一个集合?

谢谢

I'd like to create collections based on logic other than 'tags' frontmatter:

  • We use frontmatter to mark our articles with a status. I'd like to use this to provide collections for all the different statuses. Then I can easily show all posts 'in review' for example.
  • We have a yearly review policy, so I'd like a nightly build to pick up all articles within a month of this review date and add them to another collection.

So, is there a way to programmatically create a collection in 11ty?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮倦 2025-02-18 11:33:52

有时我必须是盲目的...

我在文档中找到了答案:

module.exports = function(eleventyConfig) {
  // Filter source file names using a glob
  eleventyConfig.addCollection("posts", function(collectionApi) {
    // Also accepts an array of globs!
    return collectionApi.getFilteredByGlob(["posts/*.md", "notes/*.md"]);
  });
};

Sometimes I must be word blind...

I've found the answer in the docs:

module.exports = function(eleventyConfig) {
  // Filter source file names using a glob
  eleventyConfig.addCollection("posts", function(collectionApi) {
    // Also accepts an array of globs!
    return collectionApi.getFilteredByGlob(["posts/*.md", "notes/*.md"]);
  });
};
孤檠 2025-02-18 11:33:52

在此文章他们提供了一个很好的例子唯一类别的收集,类似您可以在代码中申请状态。请检查是否有帮助。

In this article they have provided a great example of creating collection of unique categories, similar you can apply for status in your code. Please check if that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文