Hexo-next theme agrega una sección de artículo reciente

{% if theme.recent_posts %}
    <div class="links-of-blogroll motion-element {{ "links-of-blogroll-" + theme.recent_posts_layout  }}">
      <div class="links-of-blogroll-title">
        <!-- modify icon to fire by szw -->
        <i class="fa fa-history fa-{{ theme.recent_posts_icon | lower }}" aria-hidden="true"></i>
        {{ theme.recent_posts_title }}
      </div>
      <ul class="links-of-blogroll-list">
        {% set posts = site.posts.sort('-date') %}
        {% for post in posts.slice('0', '5') %}
          <li>
            <a href="{{ url_for(post.path) }}" title="{{ post.title }}" target="_blank">{{ post.title }}</a>
          </li>
        {% endfor %}
      </ul>
    </div>
{% endif %}

Pegue este código detrás next/layout/_macro/sidebar.swigdel if theme.linkscorrespondiente endif, está bien, es muy simple. . . .
Para la conveniencia de la configuración, se _config.ymlhan agregado varias variables al tema , de la siguiente manera:

recent_posts_title: 近期文章
recent_posts_layout: block
recent_posts: true

 

Publicado 120 artículos originales · elogiado 201 · 230,000 vistas +

Supongo que te gusta

Origin blog.csdn.net/wugenqiang/article/details/88581218
Recomendado
Clasificación