惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - QDuck

Handlebars.js入门教程 GHOST CMS - Handlebars Themes - Further Reading GHOST CMS - Properties GHOST CMS - Redirects GHOST CMS - Channels GHOST CMS - Content Collections GHOST CMS - Content Taxonomies GHOST CMS - Custom Routes GHOST CMS - Google AMP谷歌地图 GHOST CMS - URLs & Dynamic Routing GHOST CMS - Responsive Images 图片显示 GHOST CMS - Editor编辑器 GHOST CMS - Utility Helpers公用事业帮手 GHOST CMS - Data Helpers GHOST CMS - Functional Helpers功能助手 GHOST CMS - 标签Tag GHOST CMS - Author作者 GHOST CMS - Page 页面 GHOST CMS - Post 文章
GHOST CMS - 索引Index
QDuck · 2019-12-22 · via 博客园 - QDuck

Index

Use: {{#is "index"}}{{/is}} to detect this context.

使用:{{#is "index"}}{{/is}}来检测这个上下文。

Description描述

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 pagecontext when on subsequent pages.

index是在您的Ghost站点中主要的post列表的名称,index上下文包括主页和后续页面的主要post列表。当在您的站点的第一个页面或后续页面上的pagecontext时,索引上下文总是与home 上下文相匹配。

Routes路由

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/。所有路由都是可定制的动态路由。

Templates模板

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模板。

Data数据

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对象属性。

提供的分页对象在任何地方都是相同的。输出分页的最佳方法是使用分页助手。

Helpers助手

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}}助手是输出分页的最佳方法。这是完全可定制的。

Example Code案例代码

index.hbs

<header>
  <h1 class="page-title">{{@blog.title}}</h1>
  <h2 class="page-description">{{@blog.description}}</h2>
</header>

<main role="main">

Home

home is a special context which refers to page 1 of the index. If home is set, index is always set as well. home can be used to detect that this is specifically the first page of the site and not one of the subsequent pages.

home是一个特殊的上下文,指的是索引的第1页。如果home设置,索引总是设置好。home可以用来检测这是网站的第一个页面,而不是随后的页面之一。

Use: {{#is "home"}}{{/is}} to detect this context.

Routes

The route for the home page is always /.

主页的路径总是/。

Templates

The default template for the home page is index.hbs. You can optionally add a home.hbs template to your theme which will be used instead.

主页的默认模板是index.hbs。您可以选择添加 home.hbs模板到您的主题,将被使用。

Data

The data available on the home page is exactly the same as described in the index context. The home page's posts will always be the first X posts ordered by published date with the newest first, where X is defined by the posts_per_page setting in the package.json file.

主页上可用的数据与索引上下文中描述的完全相同。主页的贴子始终是按发布日期排序的第一个X贴子,其中X是由包中的posts_per_page设置定义在package.json文件。