# hexo-pagination

> Pagination utilities for Hexo generator plugins.

Latest version **4.0.0** (published 2024-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install hexo-pagination
pnpm add hexo-pagination
yarn add hexo-pagination
bun add hexo-pagination
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2024-07-10 |
| First published | 2014-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Tommy Chen |
| Maintainers | ertrzyiks, abnerchou, tommy351, hexobot, jlhwung, tomap, curben, yoshinorin |
| Keywords | hexo, pagination, util |

## Links

- npm: https://www.npmjs.com/package/hexo-pagination
- Repository: https://github.com/hexojs/hexo-pagination
- Homepage: https://hexo.io/
- Issues: https://github.com/hexojs/hexo-pagination/issues
- npm.io page: https://npm.io/package/hexo-pagination

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2024-07-10
- 1.0.0-rc1 (next) — 2019-08-14
- 3.0.0 — 2022-10-12
- 2.0.0 — 2021-06-03
- 1.0.0 — 2019-08-26
- 0.1.0 — 2016-06-13
- 0.0.2 — 2014-12-29
- 0.0.1 — 2014-12-26

## README

# hexo-pagination

[![Build Status](https://github.com/hexojs/hexo-pagination/workflows/Tester/badge.svg)](https://github.com/hexojs/hexo-pagination/actions?query=workflow%3ATester)
[![NPM version](https://badge.fury.io/js/hexo-pagination.svg)](https://www.npmjs.com/package/hexo-pagination)
[![Coverage Status](https://img.shields.io/coveralls/hexojs/hexo-pagination.svg)](https://coveralls.io/r/hexojs/hexo-pagination?branch=master)

Pagination utilities for [Hexo] generator plugins.

## Installation

```bash
$ npm install hexo-pagination --save
```

## Usage

### pagination(base, posts, [options])

| Option           | Description                                     | Default                |
| ---------------- | ----------------------------------------------- | ---------------------- |
| `perPage`        | Posts displayed per page                        | `10`                   |
| `format`         | URL format                                      | `page/%d/`             |
| `layout`         | Layout. This value can be a string or an array. | `['archive', 'index']` |
| `data`           | Extra data                                      | `{}`                   |
| `explicitPaging` | Number the first page. e.g. `page/1/index.html` | `false`                |

For example:

```js
var pagination = require("hexo-pagination");

pagination("/tags/hexo", [], {
  perPage: 10,
  format: "page/%d/",
  layout: ["archive", "index"],
  data: {
    tag: "hexo",
  },
});
```

This function returns an array containing objects with 3 properties: `path`, `layout`, `data`.

| Data          | Description                                       |
| ------------- | ------------------------------------------------- |
| `base`        | Base URL                                          |
| `total`       | Total pages                                       |
| `current`     | Current page number                               |
| `current_url` | Path of the current page (which equals to `path`) |
| `posts`       | The slice of posts for the current page           |
| `prev`        | Previous page number                              |
| `prev_link`   | The path to the previous page                     |
| `next`        | Next page number                                  |
| `next_link`   | The path to the next page                         |

## License

MIT

[Hexo]: https://hexo.io/

---
_Source: https://npm.io/package/hexo-pagination · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
