Bigcommerce模具-在首页上显示博客文章 [英] Bigcommerce Stencil - Display Blog Posts on Homepage

查看:51
本文介绍了Bigcommerce模具-在首页上显示博客文章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望使用Stencil/Handlebars在首页上显示博客文章.到目前为止,我已经尝试了以下代码,但无济于事:

We're looking to display blog posts on the homepage using Stencil/Handlebars. So far, I've tried the code below to no avail:

<ul>
{{#each blog}}
<li><a href="{{url}}">{{title}}</a></li>
{{/each}}
</ul>

AND

<ul>
{{#each blog.post}}
<li><a href="{{url}}">{{title}}</a></li>
{{/each}}
</ul>

博客对象是否可能在主页上不可用?似乎有点愚蠢,无法在我想要的地方使用Blog对象...?

Is it possible that the Blog object is not available on the homepage? Seems a little silly not to be able to use the Blog object wherever I want...?

提前谢谢!

推荐答案

为了确保最佳性能,默认情况下,我们不会在每个页面上加载所有资源.您可以使用文档 https://中在此处定义的frontmatter调用来获取博客资源. stencil.bigcommerce.com/docs/front-matter-variables

In order to ensure best performance, we do not load up all resources on each page by default. You can pull in the blog resource by using the frontmatter invocation defined here in the documentation https://stencil.bigcommerce.com/docs/front-matter-variables

在home.html的顶部,您应该有一个类似这样的部分:

At the top of your home.html you should have a section like this:

---
blog:
    recent_posts:
---

存在后,您应该能够在呈现上下文中访问博客文章数据.

Once that exists you should be able to access the blog post data inside the rendering context.

这篇关于Bigcommerce模具-在首页上显示博客文章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆