Giter Site home page Giter Site logo

Comments (17)

sverrirs avatar sverrirs commented on May 20, 2024 2

Hmm, you're right. Sorry I misunderstood. This is indeed a confusing behaviour as collections work in an OR way but it seems that I implemented the others to have an AND. I will have to investigate this further. Give me a few days. :)

from jekyll-paginate-v2.

bradonomics avatar bradonomics commented on May 20, 2024 2

This still doesn't seem to be working. I've cloned the examples and have tried all the combinations of adding categories to the frontmatter discussed above. The only results I get are no filtering (meaning all posts are shown), or no output at all.

Any idea when a fix might be added?

Has anyone found a work-around for paginating multiple categories?

from jekyll-paginate-v2.

rrees avatar rrees commented on May 20, 2024 1

@ibrado so upgrading the gem got rid of the problem of the page not generating but using categories instead of category resulted in no filtering of the posts being paginated. I'm checking our frontmatter against that in the example now.

from jekyll-paginate-v2.

ibrado avatar ibrado commented on May 20, 2024 1

Ok, so the "categories string is split by space" is a Jekyll thing. Given this, the correct JPv2 syntax for posts would be

category: cars, grand touring, etc (spaces after the comma don't matter)

or

categories:
  - cars
  - grand touring
  - etc

I updated examples/02-category/cars/_posts to reflect this, and added 3 more examples under examples/02-category/categories. I also added support for categories: in pagination pages.

I've pushed my changes to my fork's "or-filter" branch in preparation for a PR. Would appreciate some tests, thanks...

gem "jekyll-paginate-v2", :github => "ibrado/jekyll-paginate-v2", :branch => "or-filter"

Here's a screenshot of "Porsche, Mercedes, & Toyota" with 3 items per pagination page:

screenshot 2018-01-23 at 5 27 45 am

from jekyll-paginate-v2.

sverrirs avatar sverrirs commented on May 20, 2024

Hi Mark,
The front matter you posted looks good to me at first glance. I'm sorry but I can't test it right now but you should be able to iterate multiple categories the way you're doing it. There is an implicit 'OR' between the values.

There is an example 2 project in the source that you could use as a test, this example paginates on multiple categories like you want. Check to see if that works. If the example works then maybe something is going wrong with your project, if the sample however also doesn't work maybe there is a larger issue with your setup or there might be a regression bug in the source. https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples/02-category

from jekyll-paginate-v2.

mdo avatar mdo commented on May 20, 2024

I don't see an example there that creates a post loop to pull in all posts from any of the multiple categories. Perhaps I should've expanded on the code snippet in my first comment, but let's instead look at the 02-category example page, byname.md:

---
layout: home
title: By Name
permalink: /name/
pagination:
enabled: true
category: cars
permalink: /:num/
sort_field: 'title'
sort_reverse: false
---

If you change the category: cars to category: porsche, mercedes, the page will not exist when Jekyll recompiles the page.

from jekyll-paginate-v2.

rrees avatar rrees commented on May 20, 2024

We have just encountered this bug too, is there any update on it?

from jekyll-paginate-v2.

ibrado avatar ibrado commented on May 20, 2024

Hi @mdo, @rrees,

Have you tried the latest gem (v1.9.2) for the "page will not exist" problem, and using "categories" instead of "category"? This line has "categories" hardcoded. I tried @mdo's example with

categories: porsche, mercedes

and it worked.

from jekyll-paginate-v2.

rrees avatar rrees commented on May 20, 2024

@ibrado I did try categories and it didn't work I'll update the Gem and see what happens

from jekyll-paginate-v2.

rrees avatar rrees commented on May 20, 2024

Okay, our frontmatter does match the example but filtering does not occur when categories are used in the pagination configuration

from jekyll-paginate-v2.

ibrado avatar ibrado commented on May 20, 2024

Ok, I took another look at the source code here and here. I think categories was a red herring, sorry. Please try:

  1. Removing spaces between category names, e.g. category: porsche,mercedes; or
  2. Using an array:
category:
  - porsche
  - mercedes

If that works, I could make a PR to allow spaces after commas (or semi-colons, as it turns out).

from jekyll-paginate-v2.

ibrado avatar ibrado commented on May 20, 2024

Am trying this out now myself. I just noticed the intersect_arrays call, d'oh. Digging deeper.

from jekyll-paginate-v2.

ibrado avatar ibrado commented on May 20, 2024

Made some progress but cannot figure out why JPv2 is getting incorrectly-split categories (split at a space) immediately at generator startup.

["cars", "cars,", "grand", "touring,", "Porsche,", "sports", "car"]
from
categories: cars, grand touring, Porsche, sports car

Otherwise, I have categories using "or" now (on my local machine). Oh well. I'll get back to this.

from jekyll-paginate-v2.

ibrado avatar ibrado commented on May 20, 2024

I've been thinking about this, and an "and" filter still makes sense in certain cases, e.g. in the documentation we have an example for category: software, ruby. If I also have Java software, they would of course also show up if we just use a pure "or" filter, which is not what I would want.

Should we support both "and" and "or"? One way to do it would be to use the "and" filter for "category" -- which kinda makes sense since "ruby software" could be thought of as a "singular" category -- and use the "or" filter for "categories". OTOH, this might be introducing confusing behavior. But then again, having something like category: software && ruby might be unnecessarily complex.

Or maybe specify something like (category_|tag_)filter: all/any? Probably the cleanest solution, but it might be feature creep.

Whichever way, using an "or" filter exclusively might break existing sites that rely on JPv2's use of an "and" filter, so we have to keep that in mind...

Any preferences/thoughts on this matter, @sverrirs?

from jekyll-paginate-v2.

sverrirs avatar sverrirs commented on May 20, 2024

I've been thinking about this and one thing I've come up with is similar to what you suggested. Basically to leverage a global setting that controls whether multiple values in tags/categories/collections are interpreted in a AND or OR relationship.
I haven't yet come up with a solution I'm 100% happy with though...

from jekyll-paginate-v2.

ibrado avatar ibrado commented on May 20, 2024

I'm actually cleaning up a branch in preparation for a PR for this based on my last idea (*filter: any/all) :-D I'll push in a while; maybe you can build on it...

BTW, collections are always an "or", right? Since a doc can only belong to one..? I haven't added filters for collections.

from jekyll-paginate-v2.

pmcvtm avatar pmcvtm commented on May 20, 2024

It looks like the changes from #73 have since been reverted for version 3.0.
Rolling down to version 2.0 (which required also downgrading to Jekyll 3) and following the pattern laid out in that PR worked for me:

categories:
   values:
     - porche
     - mercedes
   matching: any

Hopefully there is a plan to re-introduce it in the new version (like #208)?

from jekyll-paginate-v2.

Related Issues (20)

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.