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

Centralize pagination/canonical meta URL generation in Document #3077

Merged
merged 5 commits into from
Dec 3, 2021

Conversation

askvortsov1
Copy link
Sponsor Member

@askvortsov1 askvortsov1 commented Sep 22, 2021

Currently, our Document class does not support generating meta prev/next URLs. With this PR, content can set page and hasNextPage on the Document object. This, in turn, will appropriately generate next/prev links, and configure the canonical URL properly.

Questions for Reviewers:
As part of this, we introduce a helper function to add/override/remove params from URLs. Is this the best place for it?

As an alternative approach, we could create a generic AbstractPaginatedContent class with methods, and move logic into there. Then, Document would just have public fields for nextPageUrl and prevPageUrl. This would let Document focus on arrangement/presentation, and avoid hardcoding logic for a pagination scheme. On the other hand, if we have centralized, defined logic for a pagination scheme, we're less likely to run into issues.

@askvortsov1
Copy link
Sponsor Member Author

Before merging, we'll also want to append ": Page X" on non-first-pages to the page title.

src/Frontend/Document.php Outdated Show resolved Hide resolved
Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving pending the title change mentioned in the comment above.

@askvortsov1
Copy link
Sponsor Member Author

@tankerkiller125 @SychO9 re-requesting review, as I've refactored the basic title driver to use translations for layout.

Specific issues:

  • Naming of translation keys
  • The layout itself (did I put : Page x in the right place)

It's an implementation detail, and can be made available on specific implementations as needed.
@askvortsov1 askvortsov1 merged commit dcc9868 into master Dec 3, 2021
@askvortsov1 askvortsov1 deleted the as/pagination-content branch December 3, 2021 18:31
@askvortsov1 askvortsov1 added this to the 1.2 milestone Dec 3, 2021
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

Successfully merging this pull request may close these issues.

3 participants