【问题标题】:How do I display most recent blog post on Octorpess/Jekyll landing page如何在 Octorpess/Jekyll 登陆页面上显示最新的博客文章
【发布时间】:2014-10-11 14:05:07
【问题描述】:

我为我的 octopress 网站创建了一个登录页面,我希望在主页上显示最新的博客文章,但只显示最新的博客。我不太确定如何进行。有没有像{% include post %} 这样的代码可以让我这样做?

谢谢。

【问题讨论】:

    标签: blogs jekyll octopress


    【解决方案1】:

    像往常一样,我倾向于在询问后找到解决方案。

    首页:

    <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>
    

    在这里找到解决方案:https://gist.github.com/nimbupani/1421828

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-29
      相关资源
      最近更新 更多