我需要在BigCommerce 主题的主页上显示一系列品牌。主题是使用 Stencil 和 Handlebars.js。我在页面顶部的 Front-matter 块如下:
页面顶部的YAML 。
---
carousel: true
products:
new:
limit: {{theme_settings.home-new-products}}
featured:
limit: {{theme_settings.home-featured-products}}
top_sellers:
limit: {{theme_settings.home-top-selling-products}}
blog:
recent_posts:
limit: 3
summary: {{theme_settings.home-blog-summary-length}}
brands:
limit: {{theme_settings.brands-count}}
---
Handlebars.js在主页下方。
<ul class="brand-items-list">
{{#each brands}}
<li class="brand-item {{#unless image}}no-brand-image{{/unless}}">
{{#if image}}
<figure class="brand-item-image-container">
<a href="{{url}}">
<img
class="brant-item-image brand-name"
src="{{getImage image 'thumb'}}"
alt="{{name}}"
>
<span class="brand-name">{{name}}</span>
</a>
</figure>
{{else}}
<a class="brand-item-title" href="{{url}}">
<span class="brand-name">{{name}}</span>
</a>
{{/if}}
</li>
{{/each}}
</ul>
据我了解,品牌应该返回可以在任何页面上迭代的品牌对象集合。BigCommerce 前端文档
我遇到的问题是 {{brands }} 在主页上使用时为空。