Comments (17)
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.
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.
@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.
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:
from jekyll-paginate-v2.
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.
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
:
jekyll-paginate-v2/examples/02-category/categories/byname.md
Lines 1 to 11 in 968476c
If you change the category: cars
to category: porsche, mercedes
, the page will not exist when Jekyll recompiles the page.
from jekyll-paginate-v2.
We have just encountered this bug too, is there any update on it?
from jekyll-paginate-v2.
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.
@ibrado I did try categories and it didn't work I'll update the Gem and see what happens
from jekyll-paginate-v2.
Okay, our frontmatter does match the example but filtering does not occur when categories are used in the pagination configuration
from jekyll-paginate-v2.
Ok, I took another look at the source code here and here. I think categories
was a red herring, sorry. Please try:
- Removing spaces between category names, e.g.
category: porsche,mercedes
; or - 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.
Am trying this out now myself. I just noticed the intersect_arrays
call, d'oh. Digging deeper.
from jekyll-paginate-v2.
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.
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.
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.
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.
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)
- `sort_reverse` is actually `false` if omitted HOT 3
- next/previous button in post page
- Extensionless numbered permalink pages filename wrong
- Wrong pagination link HOT 1
- Paginator object created for tags and collections with only hidden posts
- BUG: autopages only seeks layout file in _layouts folder regardless of what's specified in layouts_dir
- sort_field name with capitalization problem
- d710a8a903786e3277c43fd738258a8adb3b9996
- With offset config, total posts/items is incorrect HOT 2
- Avoid using the index file name, when accessing the / path of the website, it shows the content of the blog page HOT 1
- What is the maximum number of jekyll Items per page HOT 1
- Subcategory
- This is compatible with Github Pages
- Posts not showing on GitHub Pages but working locally HOT 1
- pagination numbers not clickable HOT 1
- Pagination erroneously sets `page.title` on homepage (equal to `site.title`)
- Different URL permalinks for 2 different categories?
- Get Paginate to count up
- Frontmatter defaults in _config.yml are not correctly applying to pagination pages
- Can jekyll-paginate-v2 be used with jekyll-archive? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jekyll-paginate-v2.