GHOST CMS - 索引Index

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">
<!-- This is the post loop - each post will be output using this markup -->
  {{#foreach posts}}
	<article class="{{post_class}}">
 		<header class="post-header">
   		<h2><a href="{{url}}">{{title}}</a></h2>
    </header>
    <section class="post-excerpt">
 			<p>{{excerpt words="26"}} <a class="read-more" href="{{url}}">...</a></p>
    </section>
    <footer class="post-meta">
      {{#if primary_author.profile_image}}<img src="{{primary_author.profile_image}}" alt="Author image" />{{/if}}
      {{primary_author}}
      {{tags prefix=" on "}}
      <time class="post-date" datetime="{{date format=‘YYYY-MM-DD‘}}">{{date format="DD MMMM YYYY"}}</time>
    </footer>
  </article>
  {{/foreach}}

</main>

<!-- Previous/next page links - displayed on every page -->
{{pagination}}

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.

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.

原文地址:https://www.cnblogs.com/QDuck/p/12080433.html

时间: 2024-08-30 13:39:06

GHOST CMS - 索引Index的相关文章

GHOST CMS - 配置 Config

Config For self-hosted Ghost users, a custom configuration file can be used to override Ghost's default behaviour. This provides you with a range of options to configure your publication to suit your needs. 对于自承载的Ghost用户,可以使用自定义配置文件覆盖Ghost的默认行为.这为您提供

Oracle之索引(Index)实例讲解 - 基础

Oracle之索引(Index)实例讲解 - 基础 索引(Index)是关系数据库中用于存放表中每一条记录位置的一种对象,主要目的是加快数据的读取速度和数据的完整性检查.索引的建立是一项技术性要求非常高的工作. 一般在数据库设计阶段就要考虑到如何设计和创建索引. 1. 创建索引 创建索引的语法: CREATE [UNIQUE] INDEX [schema.] index ON [schema.] table (column [ASC | DESC], column [ASC | DESC]...

Handlebars.js循环中索引(@index)使用技巧(访问父级索引)

使用Handlebars.js过程中,难免会使用循环,比如构造数据表格.而使用循环,又经常会用到索引,也就是获取当前循环到第几次了,一般会以这个为序号显示在页面上. Handlebars.js中获取循环索引很简单,只需在循环中使用{{@index}}即可. 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <META http-equiv=Content-Type content="text/html; charset=utf-

SQL Server 索引(index) 和 视图(view) 的简单介绍和操作

--索引(index)和视图(view)-- --索引(index)----概述: 数据库中的索引类似于书籍的目录,他以指针形式包含了表中一列或几列组合的新顺序,实现表中数据库的逻辑排序.索引创建在数据表或者视图的字段上,生成索引页,存放于数据库中.--分类:在SQL Server中,根据索引的作用和存储方式的不同,将索引分为聚集索引和非聚集索引两类. 1)聚集索引 :指数据库的物理顺序与被创建索引的字段顺序完全相同.同一个数据表最多只能创建一个聚集索引.默认情况下主键自动被创建为聚集索引.聚集

PLSQL_性能优化索引Index介绍(概念)

2014-06-01 BaoXinjian In Capgemini 一.摘要 在PLSQL查询优化中,使用和接触最多的应该是索引Index这个概念,个人也觉得对Index选择和优化是程式优化过程中比较重要的概念,特别是刚开始接触PLSQL性能优化 索引的一些概念 一个索引可以由一个或多个列组成, 对列设置索引其实就是对列的内容按一定的方式进行排序,检索数据的时候,检索排过序的数据,检索到最后一个有效数据之后就跳出检索 这样就不必进行全表扫描了,同时可以应用很多算法提高检索效率 数据库多用二分法

关于分区技术的索引 index

分区系列篇: 关于oracle分区技术--初了解  http://blog.csdn.net/wanghui5767260/article/details/39158873 关于分区技术的索引:           http://blog.csdn.net/wanghui5767260/article/details/39181027 关于分区技术---索引 Index 一.   分区索引分类: 本地前缀分区索引(local prefixedpartitioned index) 全局分区索引(g

GHOST CMS - 创建自定义主页 Creating a custom home page

创建自定义主页 Creating a custom home page 为你的网站创建一个自定义的主页是一个让你从人群中脱颖而出的好方法,并把你自己独特的印记存放在你的网上.本教程向您展示了如何在Ghost中自定义和开发自己的自定义主页. Creating a custom home page for your site is a great way to set yourself apart from the crowd and put your own unique stamp on you

数据库中的索引Index

索引就像一本书的目录,而书中的索引是对一个词语的列表,其中注明了包含各个词的页码.数据库中的索引 是某一个表中一列或者若干列值的集合和相应的只想表中物理标识这些值的数据页的逻辑指针清单. 索引的作用: 1.通过创建唯一索引,可以保证数据记录的唯一性: 2.可以大大的加快数据检索的速度: 3.可以加速表与表之间的连接: 4.在使用ORDER BY 和GROUP BY 子句中进行检索数据是,可以显著减少查询中分组和排序的时间: 5.使用索引可以在检索数据的过程中使用优化隐藏器,提高系统性能: 索引分

SQL大圣之路笔记——SQL 创建索引 index

1 --创建索引的标准:根据实际的sql语句进行分析,’列’出现在where中的次数较多,时间损耗较大,则为这个‘列’建立索引, 2 3 --注意:不是越多越好,因为没建立一个‘列’索引,都要排序存储一次,会让数据库文件变大 4 5 6 --创建索引 7 create index index_name 8 on 表名(列名)