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

Add a pagination component #832

Merged
merged 175 commits into from
Jan 14, 2023
Merged

Add a pagination component #832

merged 175 commits into from
Jan 14, 2023

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Jan 13, 2023

About

Adds a class to aid in creating paginated pages, and with a corresponding component to render the links. The PR does not implement any actual pagination, just the framework to do so.

Cherry picks the pagination feature from #685

See also #56

Usage

Simply create a paginator instance with a collection or array of items (like pages), and render the component. You will also likely need to find some way to pass the current page being rendered (if you're on pagination page 3, pass that to the constructor)

@php
    $paginator = new \Hyde\Framework\Features\Paginator(
        items: \Hyde\Pages\MarkdownPost::getLatestPosts(), // The items to paginate
        pageSize: 25, // How many items to show on each page
        currentPageNumber: 3, // The current page index
        paginationRouteBasename: 'posts' // Links will be 'posts/page-1.html' instead of 'page-1.html'
    )
@endphp
@include('hyde::components.pagination-navigation')

Screenshots

Verbose version:

localhost_8080_ (2)
localhost_8080_ (3)

Compact version:
localhost_8080_ (5)
localhost_8080_ (4)

caendesilva and others added 30 commits January 13, 2023 20:06
Update PaginationService.php
This simplifies the class usage, and since the class is completely useless before generation there is no reason the developer should have to call the method manually.
Hopefully this class can be used outside of publications as well
Breaks with the Laravel naming rules in favour of fluency
@codecov
Copy link

codecov bot commented Jan 13, 2023

Codecov Report

Merging #832 (8de814b) into master (989b308) will not change coverage.
The diff coverage is 100.00%.

@@              Coverage Diff              @@
##              master      #832     +/-   ##
=============================================
  Coverage     100.00%   100.00%             
- Complexity      1209      2490   +1281     
=============================================
  Files            145       292    +147     
  Lines           3186      6522   +3336     
=============================================
+ Hits            3186      6522   +3336     
Impacted Files Coverage Δ
...ges/framework/src/Framework/Features/Paginator.php 100.00% <100.00%> (ø)
...k/Features/Blogging/Models/RemoteFeaturedImage.php 100.00% <0.00%> (ø)
...mework/src/Foundation/Concerns/BootsHydeKernel.php 100.00% <0.00%> (ø)
...work/src/Foundation/Concerns/ManagesHydeKernel.php 100.00% <0.00%> (ø)
...ework/src/Framework/Actions/MarkdownFileParser.php 100.00% <0.00%> (ø)
...c/Framework/Features/Navigation/NavigationMenu.php 100.00% <0.00%> (ø)
...framework/src/Markdown/Models/MarkdownDocument.php 100.00% <0.00%> (ø)
...mework/Features/Session/SessionServiceProvider.php 100.00% <0.00%> (ø)
...src/Framework/Exceptions/FileNotFoundException.php 100.00% <0.00%> (ø)
...rc/Framework/Features/Metadata/PageMetadataBag.php 100.00% <0.00%> (ø)
... and 137 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@caendesilva caendesilva changed the title Cherry pick the pagination feature from publications Add a pagination component Jan 14, 2023
…if there are no routes

This means that if you set a route prefix to posts, links will be generated as posts/page-1.html, even if the route does not exist. This allows the pagination links to be generated outside of the kernel (such as in a post build task)
@caendesilva caendesilva marked this pull request as ready for review January 14, 2023 11:17
@caendesilva
Copy link
Member Author

I wonder if we could add a helper method that generates the paginated virtual pages / blade pages (using a specified template) this could then be used in a provider when booting to inject those pages into the page collection. Something for another PR.

@caendesilva caendesilva merged commit 0f788a5 into master Jan 14, 2023
@caendesilva caendesilva deleted the cherry-pick-pagination-feature branch January 14, 2023 11:21
caendesilva added a commit that referenced this pull request Feb 12, 2024
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.

2 participants