Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Apr 19, 2024
1 parent 66eb314 commit 140cbcb
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,50 @@ Pagination utilities for [Hexo] generator plugins.

## Installation

``` bash
```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 |
| 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');
```js
var pagination = require("hexo-pagination");

pagination('/tags/hexo', [], {
pagination("/tags/hexo", [], {
perPage: 10,
format: 'page/%d/',
layout: ['archive', 'index'],
format: "page/%d/",
layout: ["archive", "index"],
data: {
tag: 'hexo'
}
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
| 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

Expand Down

0 comments on commit 140cbcb

Please sign in to comment.