adisaktijrs / hexo-theme-minima

A lightweight dark/light theme for Hexo.js
https://adisaktijrs.github.io/minima
MIT License
225 stars 51 forks source link

Need a function Next & Prev post #13

Open ghost opened 3 years ago

ghost commented 3 years ago

Need add function Next & Prev post in footer post

Exemple from njk:

        {%- if theme.post_navigation and (post.prev or post.next) %}
          {%- set prev = post.prev if theme.post_navigation === 'right' else post.next %}
          {%- set next = post.next if theme.post_navigation === 'right' else post.prev %}
          <div class="post-nav">
            <div class="post-nav-item">
              {%- if prev %}
                <a href="{{ url_for(prev.path) }}" rel="prev" title="{{ prev.title }}">
                  <i class="fa fa-chevron-left"></i> {{ prev.title }}
                </a>
              {%- endif %}
            </div>
            <div class="post-nav-item">
              {%- if next %}
                <a href="{{ url_for(next.path) }}" rel="next" title="{{ next.title }}">
                  {{ next.title }} <i class="fa fa-chevron-right"></i>
                </a>
              {%- endif %}
            </div>
          </div>
        {%- endif %}

_config.yml post_navigation: left or right

adisaktijrs commented 3 years ago

Hi @csmov, do you have any live example/theme that uses this feature? Anyway, it looks interesting to implement it though

ghost commented 3 years ago

Hi @csmov, do you have any live example/theme that uses this feature? Anyway, it looks interesting to implement it though

Exemple from this theme https://theme-next.js.org/next-8-2-1-released/

.ejs from hexo-theme-landscape this should work

<% if (post.prev || post.next){ %>
<nav id="article-nav">
  <% if (post.prev){ %>
    <a href="<%- url_for(post.prev.path) %>" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><%= __('newer') %></strong>
      <div class="article-nav-title">
        <% if (post.prev.title){ %>
          <%= post.prev.title %>
        <% } else { %>
          (no title)
        <% } %>
      </div>
    </a>
  <% } %>
  <% if (post.next){ %>
    <a href="<%- url_for(post.next.path) %>" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><%= __('older') %></strong>
      <div class="article-nav-title"><%= post.next.title %></div>
    </a>
  <% } %>
</nav>
<% } %>

tnx for beautiful theme

adisaktijrs commented 3 years ago

Look good. It would be a nice feature for Minima. Anyway, I plan to implement it in the next release.