如何使 BigCommerce 类别描述可在导航中显示

发布于 2025-01-16 22:21:39 字数 708 浏览 4 评论 0原文

我正在为 BigCommerce 网站构建自定义导航,除了 nameurl 之外,还需要在导航项中显示类别描述。

我的导航是通过组件显示的,所以我知道我无法在那里请求 Front Matter,但由于 nameurl 已经可以访问,我认为描述也可以..

这是我的导航代码的一部分,我试图在其中显示数据。任何有关如何实现这一目标的提示将不胜感激!

{{#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 技术交流群。

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

发布评论

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

评论(1

茶底世界 2025-01-23 22:21:39

您确实需要指定使用 Front Matter 显示描述。 BC 文档中没有很好解释的是,您实际上可以在 config.json 文件中指定全局 Front Matter。假设您使用 Stencil CLI 进行本地开发,您可以编辑 config.json 文件。您将查找“资源”对象并向其附加以下代码:

"categories": {
  "description": true
}

因此,如果您的资源对象如下所示(默认 Cornerstone):

"resources": {
  "cart": false,
  "bulk_discount_rates": false,
  "shop_by_brand": {
    "limit": 10
  }
},

将其更改为:

"resources": {
  "cart": false,
  "bulk_discount_rates": false,
  "shop_by_brand": {
    "limit": 10
  },
  "categories": {
    "description": true
  }
},

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:

"categories": {
  "description": true
}

So, if your resources object looks like this (default Cornerstone):

"resources": {
  "cart": false,
  "bulk_discount_rates": false,
  "shop_by_brand": {
    "limit": 10
  }
},

Change it to this:

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