标签:lis lan dex cms sid 输出 isa ecif live
Use: {{#is "index"}}{{/is}} to detect this context.
使用:{{#is "index"}}{{/is}}来检测这个上下文。
index
is the name for the main post list in your Ghost site, the index
context includes the home page and subsequent pages of the main post list. The index
context is always paired with either the home
context when on the first page of your site, or the page
context when on subsequent pages.
index是在您的Ghost站点中主要的post列表的名称,index上下文包括主页和后续页面的主要post列表。当在您的站点的第一个页面或后续页面上的pagecontext时,索引上下文总是与home
上下文相匹配。
The index context is present on both the root URL of the site, e.g. /
and also on subsequent pages of the post list, which live at /page/:num/
. All routes are customisable with dynamic routing.
index上下文在站点的根URL上,例如/,也在post列表的后续页面上,在 /page/:num/
。所有路由都是可定制的动态路由。
The index context is rendered with index.hbs
by default. This template is required in all Ghost themes. If there is a home.hbs
present in the theme, the home page will be rendered using that instead.
Note that the index.hbs
template is also used to output the tag and author contexts, if no specific tag.hbs
or author.hbs
templates are provided.
索引上下文是用 index.hbs渲染
的,默认。此模板在所有Ghost主题中都是必需的。如果有 home.hbs
呈现在主题中的话,将使用它来呈现主页。
注意 index.hbs也可以使用模板来输出tag 和author上下文。如果没有指定tag.hbs或 author.hbs
模板。
The index
context provides templates with access to an array of post objects and a pagination object. As with all contexts, all of the @blog
global data is also available.
The number of posts provided will depend on the post per page
setting which you can configure in your package.json file. The array will provide the correct posts for the current page number, with the posts ordered chronologically, newest first. Therefore on the home page, the theme will have access to the first 6 posts by default. On /page/2/ the theme will have access to posts 7-12.
Each of the posts can be looped through using {{#foreach ‘posts‘}}{{/foreach}}
. The template code inside the block will be rendered for each post, and have access to all of the post object attributes.
The pagination object provided is the same everywhere. The best way to output pagination is to use the pagination helper.
index
上下文提供了访问post对象数组和分页对象的模板。与所有上下文一样,所有@blog全局数据也是可用的。
提供的文章数量将取决于您可以在包中配置的每页文章,设置在package.json 文件。数组将为当前页码提供正确的贴子,贴子按时间顺序排列,最先是最新的。因此,在主页上,主题将默认访问前6篇文章。在 /page/2/ ,主题将有显示发表7-12篇文章。
可以使用{{#foreach ‘posts‘}}{{/foreach}}循环每个帖子。块中的模板代码将为每个post呈现,并且可以访问所有post对象属性。
提供的分页对象在任何地方都是相同的。输出分页的最佳方法是使用分页助手。
Using {{#foreach ‘posts‘}}{{/foreach}}
is the best way to loop through your posts and output each one.
If your theme does have a tag.hbs
and author.hbs
file all outputting similar post lists you may wish to use a partial to define your post list item, e.g. {{> "loop"}}
. There‘s an example showing this in detail below.
The {{pagination}} helper is the best way to output pagination. This is fully customisable.
使用{{#foreach ‘posts‘}}{{/foreach}}是遍历帖子并输出每个帖子的最佳方法。
如果你的主题有tag.hbs和author.hbs文件所有输出类似的文章列表,您可能希望使用一个局部来定义您的文章列表项,例如{{> "loop"}}。下面有一个例子详细说明了这一点。
{{pagination}}助手是输出分页的最佳方法。这是完全可定制的。
<header>
<h1 class="page-title">