🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@astro-bryceguy/pagination

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@astro-bryceguy/pagination

This is a collection of components for paginating data and creating link navigation

unpublished
latest
Source
npmnpm
Version
2.1.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@astro-bryceguy/pagination (Deprecated)

NOTE This package is old and deprecated, you can find a better version of these components here: astro-headless-ui

This is a collection of components for paginating data and creating link navigation

<Paginate>

Paginate an array

Astro's paginate() function from getStaticPaths() inside of a component.

How do I use?

Example:

<Paginate page={Astro.params.page} data={await fetch('https://jsonplaceholder.typicode.com/posts').then(response => response.json())}>
    {page => (
        <section>
            { page.data.map(post => (
                <article>
                    <h2>{post.title}</h2>
                    <p>{post.body}</p>
                </article>
            ))}
        </section>
    )}
</Paginate>

<Pagination>

Create link navigation using objects

How do I use?

Example:

<Pagination url="/posts" total="22" current="11" theme="inline"></Pagination>

Note: Recommended to use <AdvancedPagination>

<AdvancedPagination>

Create link navigation using slots

How do I use?

Example:

<AdvancedPagination index total="22" current="11">
    <f slot="active">{(page) => <span>{page.number}</span>}</f>
    <f slot="disabled">{() => <span>...</span>}</f>
    {(page) => <a href={page.href}>{page.number}</a>}
</AdvancedPagination>

Examples

Pagination Example

This example uses the <Paginate> and <AdvancedPagination> components to paginate a list of posts from the JSONPaceholder API

---
import { Paginate, AdvancedPagination } from '@astro-bryceguy/pagination';

const posts = await fetch('https://jsonplaceholder.typicode.com/posts').then(response => response.json())
---

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
        <meta name="viewport" content="width=device-width" />
        <meta name="generator" content={Astro.generator} />
        <title>Astro</title>
    </head>
    <body>
        <Paginate data={posts} size="10" page={Astro.params.page}>
            { page => (
                <section>
                    { page.data.map(post => (
                        <article>
                            <h2>{post.id} - {post.title}</h2>
                            <p>{post.body}</p>
                        </article>
                    ))}
                </section>
                <nav>
                    <AdvancedPagination total={page.last} current={page.current} middle="1">
                        <f slot="active">{page => <span>{page.number}</span>}</f>
                        <f slot="disabled">{() => <span>...</span>}</f>
                        {page => <a href={page.href}>{page.number}</a>}
                    </AdvancedPagination>
                </nav>
            )}
        </Paginate>
    </body>
</html>

Keywords

astro

FAQs

Package last updated on 08 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts