2015-08-26 44 views
1

我在Jekyll生成的網站上使用paginator有一種奇怪的行爲。 我用來創建最後3個帖子列表作爲Jekyll paginator遇難post.excerpt

<ul class="post-list"> 
    {% for post in site.posts limit:3 %} 
     <li> 
     <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span> 

     <h2> 
      <a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a> 
     </h2> 
     <p>{{ post.excerpt }}</p> 
     </li> 
    {% endfor %} 
</ul> 

當我激活傑基爾的分頁程序和循環頁作爲

{% for post in site.posts %} 
<div class="post-preview"> 
    <a href="{{ post.url | prepend: site.baseurl }}"> 
     <h2 class="post-title">{{ post.title }}</h2> 
     {% if post.subtitle %} 
     <h3 class="post-subtitle"> 
      {{ post.subtitle }} 
     </h3> 
     <p>{{ post.excerpt }}</p> 
     {% endif %} 
    </a> 
    <p class="post-meta">Posted by {% if post.author %}{{ post.author }}{% else %}{{ site.title }}{% endif %} on {{ post.date | date: "%B %-d, %Y" }}</p> 
</div> 
<hr> 
{% endfor %} 

post.excerpt變空。我試圖用標準的行爲和技巧。

在_config.yml構建設置是這樣:

# Build settings 
gems: [jekyll-sitemap] 
markdown: kramdown 
highlighter: rouge 
permalink: pretty 
paginate: 5 
paginate_path: "/archives/page/:num" 

謝謝

回答

1

你已經投入了條件語句{{ post.excerpt }}表達。

{% if post.subtitle %} 
    <h3 class="post-subtitle">{{ post.subtitle }}</h3> 
    <p>{{ post.excerpt }}</p> 
{% endif %} 

所以,沒有副標題,沒有摘錄!

這是更好的:

{% if post.subtitle %} 
    <h3 class="post-subtitle">{{ post.subtitle }}</h3> 
{% endif %} 
<p>{{ post.excerpt }}</p> 

爲了使您必須循環分頁職位paginator.postssee documentation

+0

我很慚愧... – Mauro