avillafiorita / jekyll-datapage_gen

Generate one page per yaml record in Jekyll sites.
369 stars 80 forks source link

Is there any way to combine this with the paginator? #39

Closed Ketrel closed 4 years ago

Ketrel commented 6 years ago

Is there any way to combine this with paginatorv2 with custom settings? Where this makes the datapage and then paginatorv2 makes pages off of those, or is that not possible?

avillafiorita commented 6 years ago

Never tried, but it seems like pagination of index pages should work out of the box (auto pages are a different story, though.)

Have you tried and encountered issue, in which case could you elaborate on the problem you encountered?

Ketrel commented 6 years ago

I'm not sure if it's an issue or if I'm doing it wrong.

Basically I have a list of specific tags in a data file and am using datapage_gen to make a file for each which lists only the items in a collection that use that tag. That part I got working.

Doing this, I'm not sure how or where I'd add the pagination logic. If I add it to the _layouts/template.html file that the autogen is using, it doesn't work correctly, but I'm not sure that's the correct thing to do.

avillafiorita commented 6 years ago

What you are describing seems to be directly covered by the auto-pages feature of the paginator v2 gem. Quoting from the README:

The Auto-Pages is an optional feature that auto-magically generates paginated pages for all your tags, categories and collections.

If this is the case, you do not need to use datapage_gen to create one paginated page per tag, since the auto-pages feature should already do that for you.

Am I understanding your scenario correctly?

Ketrel commented 6 years ago

I don't think so.

May goal is to get /category/<tag name>.html to have pagination. That's what I'm not sure how to achieve or if it`s possible in this scenario.

(Ignore the fact that it says category, it`s just the path I wanted to use in this case for the end result)

avillafiorita commented 6 years ago

May goal is to get /category/.html to have pagination.

If I get it right: the <tag name> page contains a list of links to recipes containing <tag name>. Since you might have many posts with <tag name>, you want to paginate the <tag name> page.

If this is the case, I don't have a fast solution for your issue. The problem is that I don't know how to specify the order in which plugins are invoked and the recursive application of plugins (that is, how to impose the Jekyll first uses datapage_gen to generate the <tag name> page and then it invokes the paginator gem on the page generated by datapage_gen.)

Another possibility is extending datapage_gen to support the generation of different pages for each YML record, but I am not sure it makes sense (e.g., what should trigger the generation of multiple pages for a given YML record? How would you differentiate the content of each generated page?)

You might be better off using either one of the gems.

For instance: I see paginate-v2 supports filtering: you might consider manually creating one page per tag, rather than using a YML file.

If you have many tags, another option is writing a script which could read your YML file and generate Jekyll source files, one per tag. The script should be called before jekyll build. However, this solution "messes" with your source directory and it might require attention if you intend to remove, over time, the index page of one or more tag.

Let me know if you come out with a better solution!

Ketrel commented 6 years ago

If I get it right: the page contains a list of links to recipes containing <tag name>. Since you might have many posts with <tag name>, you want to paginate the <tag name> page.

Exactly.
I tried including pagination instructions in the front matter on the _layout datapage_gen used, but the paginator didin't function properly in that case.

Other than doing a lot of scripting, which is always an option (and something I'm doing in a minor way to create static printable versions), the only thing I can think of is to manually create the pages I want rather than using datapage_gen to do it, which is an option in this case since I'm only creating dedicated listings for 8-10 tags, the rest are just for reference (or future use).

I'm willing to try a few more things, and I'll definitely report back if I find a combination that works.

As far as using filtering on paginate-v2 that's one of the things I tried to do, but with the path being /category/<tag name>.html it would keep instead making it index.html and overwrite it each time.

Something I haven't looked into (yet) is if it's possible to instead use /category/<tag name>/index.html in which case it's possible that the two plugins may play nice. I'll probably try that this weekend and report back.

Ketrel commented 6 years ago

On second thought is it possible to use the form of /path/<data value>/index.html for the pages created by datapage_gen?

Ketrel commented 6 years ago

An update. I got them to play 80% nice by tweaking various options.
What I'm not able to figure out is a way to be able to reference in the front matter for the paginate (v2) config which item is being referenced by the autogen.

So I can get it to paginate on each tag, but I can't seem to filter if that makes sense.

Though I don't know ruby, I feel like this is something that could probably be solved within the plugin itself depending on how it references the template. I'll see if there's anything I can come up with either by not knowing ruby and hacking away at it, or at least a pseudocode representation. If I come up with something marvelous (or at least functional) I'll do a pull request. That likely won't be today though.

norahine commented 4 years ago

Hi @Ketrel, could you explain how you got datapage_gen working with pagination in the end?

jekyll-paginate-v2 seems to look in _posts dir for the list of things to paginate over, and since my posts are generated via datapage_gen, they aren't there.

Ketrel commented 4 years ago

It's been over two years since I've looked, but I do recall submitting the #41 pull request. If I recall, that was a big part in getting it to play nicely.

norahine commented 4 years ago

Thanks for the response @ketrel! In the end I decided to go with a custom pagination script.

avillafiorita commented 4 years ago

finally, merged!