Jekyll:获取前面指定子目录中的文件数量?

时间:2017-04-07 16:05:21

标签: jekyll yaml-front-matter

想象一下在页面前面指定的目录:

---
...
assets: "/assets/<project-name>"
...
---

如何确定assets'子目录中的文件数?例如:

{% assign img_dir = page.assets | append: "img/" %}

{% if <files-in-img_dir>.length > 1 %}
    // Render multiple images
{% else %}
    // Render single images
{% end if %}

截至目前,我正在使用类似下面的内容,但我希望能够根据要渲染的资产数量进行优化(导入,构建等)。

{% for asset in site.static_files %}
    {% if asset.path contains img_dir %}
         // Render
    {% endif %}
{% endfor %}

感谢。

0 个答案:

没有答案
相关问题