Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No paginator in get_section() #2473

Open
charlesrocket opened this issue Apr 13, 2024 · 10 comments
Open

No paginator in get_section() #2473

charlesrocket opened this issue Apr 13, 2024 · 10 comments

Comments

@charlesrocket
Copy link
Contributor

charlesrocket commented Apr 13, 2024

There is no way to get paginator's page (page/13, etc) permalink due to standalone variable (#691).

Trying to work around this but get_url() refuses to error:

{% set foo = get_url(path="/posts/page/10142342340101263162411010112") %}

foo should fail in this case since the test site has only 10 posts with the section's pagination set to 2.

@Keats
Copy link
Collaborator

Keats commented Apr 17, 2024

get_url doesn't check whether the path exists as some stuff gets added during the build process.

@charlesrocket
Copy link
Contributor Author

@Keats oh snap, that was my last idea. There are still sitemaps, but I have a grim feeling. All the work on the dynamic PWA cache just got cancelled because there's nowhere to pull pager permalinks from.

@Keats
Copy link
Collaborator

Keats commented Apr 19, 2024

Once we have tera2 it should be possible to revamp all the functions to get the paginator but it's far away

@charlesrocket
Copy link
Contributor Author

@Keats what about something like validate_permalink() since Tera 2 is not happening any time soon?

@charlesrocket
Copy link
Contributor Author

While there is no built-in solution, one could manually extract pagination settings and calculate required page numbers: charlesrocket/halve-z/pull/27

@ZzMzaw
Copy link

ZzMzaw commented Aug 11, 2024

Hello,

In order to set up a 'series' feature in a theme, I would need to know if pagination is reversed or not so that I can align series' pages indexes accordingly.
Everything works well in the series itself (which is a section) has I have both section and paginator variables.
Nevertheless, in the series' pages, I can just do a get_section to retrieve the series' section information and I don't have any way to retrieve pagination information.
Unfortunately, applying the workaround just above would not work in my case because my series' section has some content (and not only frontmatter).

Reversing the order of the pages listed in the section when paginate_reversed (or maybe something more meaningful such as sort_reversed) is set to true would work as well for me but I would expect it to have such a huge impact that it doesn't worth it in my opinion.

Even if adding the entire paginator seems not possible, do you think it would be possible to just add paginate_by and paginate_reversed in the serialized section returned by get_section?

Self {
relative_path: &section.file.relative,
colocated_path: &section.file.colocated_path,
ancestors: &section.ancestors,
draft: section.meta.draft,
content: &section.content,
permalink: &section.permalink,
title: &section.meta.title,
description: &section.meta.description,
extra: &section.meta.extra,
path: &section.path,
components: &section.components,
toc: &section.toc,
word_count: section.word_count,
reading_time: section.reading_time,
assets: &section.serialized_assets,
lang: &section.lang,
generate_feeds: section.meta.generate_feeds,
transparent: section.meta.transparent,
pages,
subsections,
translations,
backlinks,
}

If yes, I can try to tackle it and propose a PR in the weeks to come.
If you would prefer me to open a new issue instead of reusing this one, please tell me.

Thanks for your help and support.

@Keats
Copy link
Collaborator

Keats commented Aug 11, 2024

Even if adding the entire paginator seems not possible, do you think it would be possible to just add paginate_by and paginate_reversed in the serialized section returned by get_section

That would be fine yes

@ZzMzaw
Copy link

ZzMzaw commented Aug 14, 2024

That would be fine yes

Thanks for your feedback.

This is my first contribution and I was not able to figure out which branch I should push this modification to (master or next).
Is master dedicated to bug fixing the current version only or should we consider this small evolution to be part of it as well?

Thanks in advance for your help and support.

@Keats
Copy link
Collaborator

Keats commented Aug 14, 2024

master is only for docs update, all new features/bug fixes go on the next branch

@ZzMzaw
Copy link

ZzMzaw commented Sep 29, 2024

I just created a small PR following our discussion.
It won't completely solve the issue but may be enough in some cases.
Feel free to let me know if there is anything to change regarding this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants