【问题标题】:jekyll Multiple pagination on one pagejekyll 在一页上多分页
【发布时间】:2016-07-08 10:19:59
【问题描述】:

大家好,我是 github、jekyll 和 ruby​​ 的新手,也许这个问题已经得到解答,但作为一个新手,我很难解决这个问题。

我试图在一个页面上放置多个分页,即说我有两个 作者在博客上发布了他们的内容,所以我为他们每个人创建了一个部门,并希望为每个人单独分页。所以当前的代码是这样的:

<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
            {% for post in paginator.posts %}
                {% if post.author contains "NAME OF AUTHOR 1" %}
                <div class="post-preview">
                   <a href="{{ post.url }}">
                    <h2 class="post-title">
                        {{ post.title }}
                    </h2>
                    <h3 class="post-subtitle">
                        {{ post.description }}
                    </h3>
                   </a>
                  <p class="post-meta">Posted by <a href="#">{{ post.author }}</a> {{ post.date | date_to_string }}</p>
                </div>
                <hr>
                {% endif %}
            {% endfor %}

            <!-- Pager -->
          {% if paginator.total_pages > 1 %}
            <ul class="pager">
                {% if paginator.previous_page %}
                <li class="previous">
                    <a href="{{ paginator.previous_page_path | prepend: site.url | replace: '//', '/' }}">&larr; Newer Posts</a>
                </li>
                {% endif %}
                {% if paginator.next_page %}
                <li class="next">
                    <a href="{{ paginator.next_page_path | prepend: site.url | replace: '//', '/' }}">Older Posts &rarr;</a>
                </li>
                {% endif %}
            </ul>
         {% endif %}
        </div>

        <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
            {% for post in paginator.posts %}
                {% if post.author contains "NAME OF AUTHOR2" %}
                <div class="post-preview">
                   <a href="{{ post.url | prepend: site.url }}">
                    <h2 class="post-title">
                        {{ post.title }}
                    </h2>
                    <h3 class="post-subtitle">
                        {{ post.description }}
                    </h3>
                   </a>
                  <p class="post-meta">Posted by <a href="#">{{ post.author }}</a> {{ post.date | date_to_string }}</p>
                </div>
                <hr>
                {% endif %}
            {% endfor %}
                <!-- Pager -->
            {% if paginator.total_pages > 1 %}
            <ul class="pager">
                {% if paginator.previous_page %}
                <li class="previous">
                    <a href="{{ paginator.previous_page_path | prepend: site.url | replace: '//', '/' }}">&larr; Newer Posts</a>
                </li>
                {% endif %}
                {% if paginator.next_page %}
                <li class="next">
                    <a href="{{ paginator.next_page_path | prepend: site.url | replace: '//', '/' }}">Older Posts &rarr;</a>
                </li>
                {% endif %}
            </ul>
            {% endif %}
        </div>

同样在 _config.yml 下分页设置为 3。

我使用了带有引导程序的 jekyll(如果正确,不是 jekyll-bootstrap)并遵循了一个非常简单的教程,文件结构也非常简单。

感谢您的帮助,我在发布之前阅读了许多文档和许多帖子(总是搞砸了),所以感谢大家。

另外, 该博客托管在http://neorblog.in 和github 存储库https://github.com/neortls007idev/Blog

另外,repo 目前也没有按照上面的代码提交。

【问题讨论】:

    标签: jekyll jekyll-paginator


    【解决方案1】:

    分页适用于所有帖子。您不能为posts where author == NeoR 设置分页。

    您仍然有创建generator plugin 的解决方案。是的,出于安全原因,github pages 不接受外国插件。

    但是,简单地推送到 github 并不是唯一可用的工作流程。你可以试试this

    【讨论】:

    • 你能在 git 上帮我解决这个问题吗,就像我对 jekyll 说的新手只在几天内使用它一样
    • 我也刚读到github页面不支持jekyll插件
    • 好吧,这有帮助,但它看起来真的很复杂,我想我会尝试使用集合和 octopress-paginate
    猜你喜欢
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多