Page pagination

Hi I am creating a page pagination, how can I change to instead of

By the way, if someone has time, they can check if the code below is correct

    $filterBy = get('kategoria');
    $unfiltered = $page->children()->listed();
    $projects = $unfiltered
    ->when($filterBy, function($filterBy) {
    return $this->filterBy('category', $filterBy);

    $pagination = $projects->pagination();
    $filters = $unfiltered->pluck('category', null, true);

<main class="main">
    <h1><?= $page->title() ?></h1>
    <nav class="filter">
        <a href="<?= $page->url() ?>">All</a>
        <?php foreach ($filters as $filter): ?>
        <a href="<?= $page->url() ?>?kategoria=<?= $filter ?>"><?= $filter ?></a>
        <?php endforeach ?>

    <ul class="projects">
        <?php foreach ($projects as $project): ?>
            <a href="<?= $project->url() ?>">
                    <?= $project->image()->crop(400, 500) ?>
                        <?= $project->title() ?><br>
                        <small><?= $project->category() ?></small>
        <?php endforeach ?>

    <?php if ($pagination->hasPages()): ?>
    <nav class="pagination">
        <?php if ($pagination->hasPrevPage()): ?>
        <a href="<?= $pagination->prevPageUrl() ?>" aria-label="Go to previous page">&larr;</a>
        <?php else: ?>
        <?php endif ?>

        <span>Page <?= $pagination->page() ?> of <?= $pagination->pages() ?></span>

        <?php if ($pagination->hasNextPage()): ?>
        <a href="<?= $pagination->nextPageUrl() ?>" aria-label="Go to next page">&rarr;</a>
        <?php else: ?>
        <?php endif ?>
    <?php endif ?>

    <?php foreach ($pagination->range(3) as $r): ?>
        <a<?= $pagination->page() === $r ? ' aria-current="page"' : '' ?> href="<?= $pagination->pageURL($r) ?>">
            <?= $r ?>
    <?php endforeach ?>

Have a nice day!

variable is what you are looking for…

Thank you :slight_smile: