【发布时间】:2014-10-11 14:05:07
【问题描述】:
我为我的 octopress 网站创建了一个登录页面,我希望在主页上显示最新的博客文章,但只显示最新的博客。我不太确定如何进行。有没有像{% include post %} 这样的代码可以让我这样做?
谢谢。
【问题讨论】:
我为我的 octopress 网站创建了一个登录页面,我希望在主页上显示最新的博客文章,但只显示最新的博客。我不太确定如何进行。有没有像{% include post %} 这样的代码可以让我这样做?
谢谢。
【问题讨论】:
像往常一样,我倾向于在询问后找到解决方案。
首页:
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include custom/asides/recent_post.html %}
</div>
在单独的文档中保存到custom/asides/recent_post.html:
<h2 class="entry-title">
{% if post.title %}
<a href="{{ root_url }}{{ post.url }}" id="recent_post">{{ post.title }}</a>
{% endif %}
</h2>
<div class="entry-content">{{ content | excerpt }}</div>
<a class="btn btn-default" href="{{ root_url }}{{ post.url }}">{{ site.excerpt_link }}</a>
【讨论】: