Socket
Socket
Sign inDemoInstall

hexo-pagination

Package Overview
Dependencies
0
Maintainers
8
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

30

lib/pagination.js
'use strict';
const util = require('util');
const { format } = require('util');
function pagination(base, posts, options) {
function pagination(base, posts, options = {}) {
if (typeof base !== 'string') throw new TypeError('base must be a string!');
if (!posts) throw new TypeError('posts is required!');
options = options || {};
if (base && base[base.length - 1] !== '/') base += '/';
if (base && !base.endsWith('/')) base += '/';
const length = posts.length;
const perPage = Object.prototype.hasOwnProperty.call(options, 'perPage') ? +options.perPage : 10;
const { length } = posts;
const { format: _format, layout, data, perPage } = Object.assign({
format: 'page/%d/',
layout: ['archive', 'index'],
data: {},
perPage: 10
}, options);
const total = perPage ? Math.ceil(length / perPage) : 1;
const format = options.format || 'page/%d/';
const layout = options.layout || ['archive', 'index'];
const data = options.data || {};
const result = [];
const urlCache = {};
const urlCache = new Map();
function formatURL(i) {
if (urlCache[i]) return urlCache[i];
if (urlCache.has(i)) return urlCache.get(i);
let url = base;
if (i > 1) url += util.format(format, i);
urlCache[i] = url;
const url = i > 1 ? base + format(_format, i) : base;
urlCache.set(i, url);

@@ -28,0 +30,0 @@ return url;

{
"name": "hexo-pagination",
"version": "1.0.0",
"version": "2.0.0",
"description": "Pagination utilities for Hexo generator plugins.",

@@ -15,6 +15,6 @@ "main": "lib/pagination",

"files": [
"lib"
"lib"
],
"repository": "hexojs/hexo-pagination",
"homepage": "http://hexo.io/",
"homepage": "https://hexo.io/",
"keywords": [

@@ -29,10 +29,10 @@ "hexo",

"chai": "^4.1.2",
"eslint": "^6.0.1",
"eslint-config-hexo": "^3.0.0",
"mocha": "^6.0.2",
"nyc": "^14.1.1"
"eslint": "^7.1.0",
"eslint-config-hexo": "^4.1.0",
"mocha": "^8.1.1",
"nyc": "^15.0.0"
},
"engines": {
"node": ">=8.6.0"
"node": ">=10.13.0"
}
}

@@ -59,2 +59,2 @@ # hexo-pagination

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc