GithubHelp home page GithubHelp logo

jekyll / jekyll-paginate Goto Github PK

View Code? Open in Web Editor NEW
111.0 14.0 91.0 31 KB

NO LONGER UNDER ACTIVE DEVELOPMENT as of Jekyll 3: Pagination Generator for Jekyll

License: MIT License

Ruby 99.61% Shell 0.31% HTML 0.07%
jekyll

jekyll-paginate's Introduction

Jekyll::Paginate

Default pagination generator for Jekyll.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'jekyll-paginate'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jekyll-paginate

Usage

Once the gem is installed on your system, Jekyll will auto-require it. Just set the following configuration

Contributing

  1. Fork it ( http://github.com/jekyll/jekyll-paginate/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

jekyll-paginate's People

Contributors

dirtyf avatar envygeeks avatar jekyllbot avatar parkr avatar stargator avatar tombell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jekyll-paginate's Issues

Does sorting work at all with this plugin?

I have implemented this plugin for my site but it looks like the paginator shuffled all my posts in some way. After digging around it seems like it's impossible to do something like,
{% assign sortedPosts = paginator.posts | sort: 'post-priority' %}
with this plugin. Is this true?

(in this case post-priority is just a numerical variable in the front matter of each markdown post.)

GithubPage Posts page works only with an ending /

Hi, I know this plugin is no longer maintained, but since the new paginate-v2 is not supported by github pages, I hope to get some assistance here :)

My site's structure is pretty straightforward, with the paginated list of posts under the path :root/posts.
I achieved that with the following setup:

files tree

.
├── index.md
├── _layouts
│   ├── default.html
│   ├── home.html
│   ├── post.html
│   └── posts.html
├── posts
│   └── index.html
├── _posts
│   ├── 1986-08-01-hello-world.md
│   ├── 2017-03-09-welcome-to-jekyll.md
│   └── 2018-04-18-today.md
├── posts.md
...

_config.yml

# Plugins
plugins:
  - jekyll-paginate

# Permalinks
permalink: :title:output_ext

# Pagination
paginate: 2
paginate_path: "/posts/page:num"

In my local environment when I browse localhost:4000/posts I get redirected to localhost:4000/posts/ (note the ending /) and paginator works just fine.

On my live website when I browse davideghezzi.com/posts I don't get redirected and the paginator does not work. If I manually browse davideghezzi.com/posts/ (with the ending /) it works.

How can I address this issue?

p.s. you can find source code here https://github.com/davideghz/davideghz.github.io

Toughts on all new Jekyll pagination system

The post below is long, longer than I tought it'll be, but please read it all 😄

I hope that others including the maintainers of the project, have similar toughts on the topic and see it as a way to go forward with the project making it more feature rich and customizeable even for more complex web pages. My intention is not to fragmentize the community, thats why I posted my ideas here instead of creating another fork and just doing "my stuff".

Why I'm doing this?

Hello, like others here I'm dedicated Jekyll user and have built many websites, including my own, on Jekyll.

The most time consuming part was to find a suitable solution to produce multilingual site with customized and filtered pagination pages. Currently Jekyll pagination has no support for that. Yes, there are a lot of alternatives, each of them have different goal, but any of them exactly suitable for my needs - lack of documentation and sometimes hard or even overkill to implement.

I propose to write all new Jekyll pagination system, from scratch. Some of You might ask, why write here, why I don't just fork it and make my changes? Well I kind of did that already, but this is not the solution.

In my opinion projects like this should be kept together and developed as one which guarantees one good source of the software.

My idea is to start from scratch (we could reuse useful code), create an experimental repository, but first we should map our needs, toughts and other hardcore awesome ideas.

The ideas listed below are my personal toughts on the subject, feel free to express Your toughts. The ideas are based on my experience and from issues of the project.

If maintainers think that I'm overstepping my boundaries (I hope that I'm not 😃), feel free to close and lock this issue.

What I would like to achieve?

Architecture

Current architecture is limited only to posts. Referring to #22 I think it should be able to paginate all Jekyll content types: pages, posts and collections.

Code clarity

Make classes independent (#26). Currently there's huge hell in Pager class. The class should be completely independent and all variables should be passed to it as separate and well defined arguments.

Layouts/templates

Jekyll has a well defined layout system and for clarity we should use it instead of defining html files directly and relative of the root directory. Defining layout like myblog whould use template _layouts/myblog.html.

Pemalinks

With this way we should also separate layout from permalinks (#22). This would make a life lot of easier for multilingual page. Default permalink should point to the layout, if layout is myblog then permalink is /myblog:num. The first page is /myblog.html unless, there is a missing index.html in the same directory, then the first page is /index.html. Other pages would still be /myblog2/index.html, /myblog3/index.html etc.

Filtering

When converting my site to multilingual I researched some other plug-ins which added support for pagination by category. Since Jekyll is in my opinion pretty abstract we shouldn't focus on one filter variable category, but it should be configureable (for example, I filter my posts using language). We should also keep in mind that the frontmatter variables can have multiple values so support for lists as filter value is needed (eg filter posts by language values [ "et_EE", "en_US" ]). Also support for both include and exclude filters would be a good feature (include all category X, but exclude if also in category Y).

Sorting

Custom sorting would be awesome feature. The default should be same behavior as now (by date descending), but we should make it configurable, so we could use other fontmatter variables and values for sorting, try to detect automatically if alphabetically or chronologically. For pages and collections the default should by filename alphabetically ascending.

Avoiding existing mistakes

Both open and closed issues should be taken in consideration when building new system so we don't step on the same rake over and over again.

Compatibility

Everything must be backwards compatible. The new code must support the old config layout otherwise a lot of web pages will break and that's not acceptable.

Proposed config syntax (based on #22)

I'm proposing the configuration syntax below.

pagination:
  # Allow setting global default limits for all paginated pages
  limit: 0 # Limit how many content objects to paginate (default: 0, means all)
  page_limit: 10 # How many objects per page, used to be `paginate` (default: 0, means all)
  filter:
    # If filter is not specified or is null then all objects are
    # considered included
    include: 
      locale: en_US

  posts:
    # The global settings `limit` and `page_limit` are included here
    # but can be overwritten
    - page_limit: 15
      layout: blog # Which layout to use from `_layouts/`
      # permalink: /blog:num # Permalink syntax, used to be `paginate_path` (the default is taken from layout)
      filter:
        include:
          # en_US is included from global filters settings, et_EE and 
          # de_DE are appended.
          locale:
            - et_EE
            - de_DE
        exclude:
          category:
            - drafts
    - layout: blog_et_EE # Another posts paginator.
      permalink: /et/blog/:num # Note: /et/blog/:num and /et/blog:num are behaving differently
      filter:
        include: et_EE
        exclude: en_US
      sort:
        date: asc

  pages:
    - layout: pages
      permalink: /pages/:num
      sort:
        title: desc

  collections:
    # The collections are defined here not on the root node, because
    # this behavior would eliminate conflicts with global pagination
    # settings
    - authors:
        limit: 50
        # layout: authors # By default, taken from collection name
        # permalink: /authors:num # By default, taken from collection name
        filter: null # Disable filtering, otherwise global filters will apply

Note, that if posts, pages or collections are not defined as lists, then those objects are not considered as multipagination (if you only want one pagination page, then You can use associative arrays directly as those node's values:

pagination:
  posts:
   layout: blog

The code above would also be the shortest code to enable pagination for posts. There is no need to define permalink here and if You don't have /index.html then default permalink is considered to be that, but if You do, then first page will be /blog.html (see the Permalinks paragraph).

How could I achieve that?

As stated in the introduction, the idea is to create an experimental repository (milestone 2.0.0?) which would contain all the new Jekyll pagination. We all have our daily jobs to do, so this probably won't be finished this month, not even next or even might not be in this year, but we would have a straight goal and sight where to go next. All useful contributions from everyone would be welcome 😄 .

How can You help?

I'm slightly new to Ruby world, but I have extensive and long time knowledge of PHP, Python, various *nix shells' script languages etc. To be honest those two commits from my fork's experimental branch are basically my first serious contact with Ruby world.

Note: I don not encourage nor recommend to use this code in production, it's not a solution to existing issues, it's a hack which I quickly made to add multilingual support to my site.

Yes, I can write the code but I have no knowledge of other Ruby stuff including inline documenting, unit testing, packaging and distribution - so thats where the most of help would be needed.

Jekyll crash on invalid path in configuration

I want to preface this with saying that I am not a Ruby developer but am willing to help in anyway I can. I am also not sure if the issue is with the paginate plugin or if it is Jekyll that should not crash because of the following report.


Issue description

Jekyll will crash when watching for changes given the following configuration when it tries to auto-regenerate provided there are at least two posts inside the _posts folder.

_config.yml
paginate: 1
paginate_path: ":path/page:num"
Terminal output
Configuration file: /Users/mitmaro/Code/tmp/website.jekyll/_config.yml
            Source: /Users/mitmaro/Code/tmp/website.jekyll
       Destination: /Users/mitmaro/Code/tmp/website.jekyll/_site
      Generating...
                    done.
 Auto-regeneration: enabled for '/Users/mitmaro/Code/tmp/website.jekyll'
      Regenerating: 1 files at 2014-08-22 23:48:14 ...done.
E, [2014-08-22T23:48:14.697565 #48565] ERROR -- : run() in thread failed: different prefix: "" and "/Users/mitmaro/Code/tmp/website.jekyll":/usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/pathname.rb:500:in `relative_path_from'
/usr/local/lib/ruby/gems/2.1.0/gems/listen-2.7.9/lib/listen/adapter/darwin.rb:29:in `block in _process_event'
/usr/local/lib/ruby/gems/2.1.0/gems/listen-2.7.9/lib/listen/adapter/darwin.rb:25:in `each'
/usr/local/lib/ruby/gems/2.1.0/gems/listen-2.7.9/lib/listen/adapter/darwin.rb:25:in `_process_event'
/usr/local/lib/ruby/gems/2.1.0/gems/listen-2.7.9/lib/listen/adapter/base.rb:47:in `block (2 levels) in configure'
/usr/local/lib/ruby/gems/2.1.0/gems/rb-fsevent-0.9.4/lib/rb-fsevent/fsevent.rb:45:in `call'
/usr/local/lib/ruby/gems/2.1.0/gems/rb-fsevent-0.9.4/lib/rb-fsevent/fsevent.rb:45:in `run'
/usr/local/lib/ruby/gems/2.1.0/gems/listen-2.7.9/lib/listen/adapter/darwin.rb:21:in `_run'
/usr/local/lib/ruby/gems/2.1.0/gems/listen-2.7.9/lib/listen/adapter/base.rb:58:in `block in start'

Steps to reproduce

Step 1

Create a basic Jekyll site using the following commands:

gist for script: https://gist.github.com/MitMaro/af4680417bb95761fd0c
mkdir website.jekyll
cd website.jekyll
mkdir _layouts _posts
touch _layouts/default.md
touch _posts/2000-01-01-title1.md _posts/2000-01-02-title2.md
cat > index.html << EOF

---
layout: default

---
EOF
cat > _config.yml << EOF
paginate: 1
paginate_path: ":path/page:num"
EOF

Step 2

Build the site with Jekyll using the watch setting: jekyll build --watch

Step 3

Touch the index.html file using touch index.html

What I have deduced

The problem is the line paginate_path: ":path/page:num" in the config file as it creates pages using :path (see tree output below) which I believe is what causing the crash. Changing the line to paginate_path: "blog/page:num" fixes the problem.

Tree output
$ tree
.
├── _config.yml
├── _layouts
│   └── default.md
├── _posts
│   ├── 2000-01-01-title1.md
│   └── 2000-01-02-title2.md
├── _site
│   ├── 2000
│   │   └── 01
│   │       ├── 01
│   │       │   └── title1.html
│   │       └── 02
│   │           └── title2.html
│   ├── :path
│   │   └── page2
│   │       └── index.html
│   └── index.html
└── index.html

Versions

System: Mac OSX 10.9.2
Ruby: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
Jekyll: jekyll 2.3.0
Jekyll Paginate: 2.4.1

Conclusion

I am aware that using :path is not recommended or should be allowed given that : is generally used as a path separator on *nix systems. The reason for having :path for the paginate_path was that I had accidentally changed the wrong value in the config file. Given that the Jekyll error was almost entirely useless (at least to me) would it be possible to have either some check on the configuration variable, have it documented (perhaps this issue alone would be enough), or is this a problem with Jekyll and it should be addressed there?

Feature request: "Reverse" pagination

For a blog, we expect that the newest post will be front-and-centre, but for other types of pages, we would expect the oldest to be first, and newer items to be on later pages.

Examples: Training material, ebook, story

Right now, if we have 8 posts:

  • 2014-01-02-Chapter-1.md
  • 2014-01-03-Chapter-2.md
  • 2014-01-04-Chapter-3.md
  • 2014-01-05-Chapter-4.md
  • 2014-01-06-Chapter-5.md
  • 2014-01-07-Chapter-6.md
  • 2014-01-08-Chapter-7.md
  • 2014-01-09-Chapter-8.md

Default pagination will return them in backwards order.

Changing Index.html to specify 'reversed' ( {% for post in paginator.posts %} to {% for post in paginator.posts reversed %} (with paginate: 3), jekyll-paginate returns the posts in this order:

  • 2014-01-07-Chapter-6.md
  • 2014-01-08-Chapter-7.md
  • 2014-01-09-Chapter-8.md

  • 2014-01-04-Chapter-3.md
  • 2014-01-05-Chapter-4.md
  • 2014-01-06-Chapter-5.md

  • 2014-01-02-Chapter-1.md
  • 2014-01-03-Chapter-2.md

Absolute permalinks break paginator when permalink is specified for index file

Originally submitted by @benbalter:

Here's a fun one...

Steps to reproduce

Create a new site
Create 2 or more dummy posts
Create an index file, setting permalink: / in the yml front matter
Add a paginator loop to the index file
Specific pagination (e.g., paginate: 5) and relative_permalinks: false in _config.yml
Expected

Index.html will be paginated with the specified number of posts
Actual

Index.html has 1-2 posts (missing the rest)
Resolution

Specify relative_permalinks: true in config.yml
Don't specify a permalink in index.html's YML frontmatter
Wat.

H/t @jlord for discovering it.

See jekyll/jekyll#1625 for more details.

previous_page_path includes index.html

Moved from jekyll/jekyll#3073

paginator.previous_page_path generates base/page2 when on the third page, but for the second page the result is base/index.html which is not pretty. Shouldn't previous_page_path generate just base/ in this case?

Here is a sample fix: rovrov@088fd18

base instead of base/ (i.e. chomp("/index.html")) might be even more consistent if it always works without the trailing slash.

Now available: New Pagination Plugin (Fully backwards compatible)

Posting here since none of the open issues are getting any real replies and people seem to still be frustrated about the decommissioning of this gem.

I've recently re-written the pagination plugin which I hope is a viable alternative to the old one. It is fully backwards compatible and supports a slew of new frequently requested features.

Check it out, I'd really welcome more testers :)
https://github.com/sverrirs/jekyll-paginate-v2

Pagination doesn't generate page directories when permalink is set

(Issue copied from jekyll/jekyll#3471)

This tripped me up for 30 mins or so. I was trying to paginate /blog/index.html, but I had permalink: /blog set (I'm a n00b and I don't know what I'm doing). I did have paginate_path set correctly. The result was that visiting /blog would always start on the last page of pagination and be unable to find the other pages. None of the /blog/pageN/directories were generated.

In retrospect I can kind of understand what's going on. I suppose jekyll wanted to write _site/blog/page2/index.html, but permalink overrode it to write _site/blog/index.html, so each page was written to the same file. Perhaps an error when you keep overwriting the same file would help n00bs like me!

allow more isolated use of Jekyll::Paginate::Pager

I'm using Jekyll::Paginate::Pager to build tag indexes for my blog: https://github.com/stevecrozz/lithostech.com/blob/master/_plugins/tag_indexes.rb

But since this class references site.config inside ::paginate_path (https://github.com/jekyll/jekyll-paginate/blob/master/lib/jekyll-paginate/pager.rb#L66) I cannot reuse this class for paginating anything that doesn't share the same 'paginate_path.' I propose we modify the ::paginate_path method to accept config as an argument so I can reuse it.

If you agree, I can supply a PR and a test case.

Insistence on using index.html as the pagination template

I'm using the Beautiful Jekyll theme to create a small personal website. On my site, I don't want posts to appear in the front page, the index page; so I removed the relevant code from index.html (in fact, I got rid of it in favor of an index.md with static content). Now I get the warning message:

Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination.

I found this issue page on this matter at the Jekyll core project, where it's claimed this is a Jekyll-paginate issue. Well, here I am reporting it to you :-(

I'll state that I'm willing to move the pagination code elsewhere, so maybe there's some workaround in my case.

Index gets last page, no other page is generated

This is exactly the same problem described at jekyll/jekyll#1063 and jekyll/jekyll#1058, but I'm seeing it both locally on a Linux system and in GitHub pages.

You can find an example of the problem here:

As you see, the index shows page 3 and actual pages 2 and 3 are nonexistant.

Now, I really don't know whose fault this is, mine or jekyll's, but as the symptoms are not new, I'm assuming jekyll's. Is there some workaround I can use?

How to make configuration for category pagination?

I have installed the plugin jekyll-paginate, and read the Usage.

The usage said:

Usage
Once the gem is installed on your system, Jekyll will auto-require it. Just set the following configuration.

This doc did not express clearly. Thus I don't know how to set configuration. Could you help me?

Thanks! Have a nice day.

jekyll 3.8.5 | Error: File exists @ dir_s_mkdir jekyll/_site/tag/inspire

I am using jekyll 3.8.5 and jekyll-paginate (1.1.0)
when I run my docker-compose I get this error:
jekyll 3.8.5 | Error: File exists @ dir_s_mkdir jekyll/_site/tag/inspire My _config.yml

plugins:
  - jekyll-paginate

# Defaults
defaults:
  -
    scope:
      path: "" # an empty string here means all files in the project
      type: "posts" # previously `post` in Jekyll 2.2.
    values:
      layout: "post"
  -...
paginate: 5
paginate_path: "/news/page:num/"

Anyone have an idea about how to fix that, I am new with jekyll.
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.