zoukankan      html  css  js  c++  java
  • GHOST CMS

    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.

    主页的默认模板是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文件。

  • 相关阅读:
    C#开发BIMFACE系列44 服务端API之计算图纸对比差异项来源自哪个图框
    C#开发BIMFACE系列43 服务端API之图纸拆分
    C#开发BIMFACE系列42 服务端API之图纸对比
    利用 OpenVINO 进行推理加速(一)
    虚拟化技术概述(一)
    利用目标跟踪来提高实时人脸识别处理速度
    目标追踪(Object Tracking)概念的简要介绍
    Python3 使用IMAP接收邮件
    Git使用
    Git基础
  • 原文地址:https://www.cnblogs.com/QDuck/p/12080433.html
Copyright © 2011-2022 走看看