如何使 BigCommerce 类别描述可在导航中显示
我正在为 BigCommerce 网站构建自定义导航,除了 name
和 url
之外,还需要在导航项中显示类别描述。
我的导航是通过组件显示的,所以我知道我无法在那里请求 Front Matter,但由于 name
和 url
已经可以访问,我认为描述也可以..
这是我的导航代码的一部分,我试图在其中显示数据。任何有关如何实现这一目标的提示将不胜感激!
{{#each children}}
<li class="navigation__submenu-item">
<a class="navigation__submenu-action has-subMenu"
href="{{url}}"
>
{{#if image}}
<img class="navigation__submenu-img" src="{{getImage image}}" alt="{{image.alt}}" />
{{/if}}
<div>{{name}}</div>
<small class="navigation__submenu-msg">{{description}}</small>
</a>
</li>
{{/each}}
I am building a custom navigation for a BigCommerce site and need to display category descriptions within the navigation items in addition to name
and url
.
My navigation is being displayed via a component so I know I can't request Front Matter there, but as name
and url
are already accessible I thought the description would be as well..
Here is part of my navigation code where i'm trying to display the data. Any tips on how to achieve this would be appreciated!
{{#each children}}
<li class="navigation__submenu-item">
<a class="navigation__submenu-action has-subMenu"
href="{{url}}"
>
{{#if image}}
<img class="navigation__submenu-img" src="{{getImage image}}" alt="{{image.alt}}" />
{{/if}}
<div>{{name}}</div>
<small class="navigation__submenu-msg">{{description}}</small>
</a>
</li>
{{/each}}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确实需要指定使用 Front Matter 显示描述。 BC 文档中没有很好解释的是,您实际上可以在 config.json 文件中指定全局 Front Matter。假设您使用 Stencil CLI 进行本地开发,您可以编辑 config.json 文件。您将查找“资源”对象并向其附加以下代码:
因此,如果您的资源对象如下所示(默认 Cornerstone):
将其更改为:
You do indeed need to specify to show the description with Front Matter. Something that is not explained well in the BC documentation is that you can actually specify global Front Matter in the config.json file. Assuming you are developing local with the Stencil CLI, you can edit the config.json file. You will look for the "resources" object and append the following code to it:
So, if your resources object looks like this (default Cornerstone):
Change it to this: