Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
metalsmith-pagination
Advanced tools
A Metalsmith plugin for paginating arrays and collections.
npm install metalsmith-pagination --save
To paginate an array of files, you need to have a property that points to the location of the collection you want to paginate. The value should be an options object that will be used to initialize the plugin.
P.S. Make sure the pagination middleware is defined after the files array exists, but before the template middleware renders.
Install via npm and then add metalsmith-pagination
to your metalsmith.json
:
{
"plugins": {
"metalsmith-pagination": {
"collections.articles": {
"perPage": 5,
"template": "index.jade",
"first": "index.html",
"path": "page/:num/index.html",
"filter": "private !== true",
"pageMetadata": {
"title": "Archive"
}
}
}
}
}
Install via npm, require the module and .use
the result of the function.
var pagination = require('metalsmith-pagination')
metalsmith.use(pagination({
'collections.articles': {
perPage: 5,
template: 'index.jade',
first: 'index.html',
path: 'page/:num/index.html',
filter: function (page) {
return !page.private
},
pageMetadata: {
title: 'Archive'
}
}
}))
10
).index.html
, instead of page/1/index.html
).pagination
object, so you can use :name
, :num
or :index
.false
).perPage
). Useful for paginating by other factors, like year published (E.g. date.getFullYear()
).file
passed to groupBy
to get the page name.Buffer.from('')
). Useful for metalsmith-in-place (especially with pageMetadata
).The pageMetadata
option is optional. The object passed as pageMetadata
is merged with the metadata of every page generated. This allows you to add arbitrary metadata to every page, such as a title variable.
Within the template you specified, you will have access to pagination specific helpers:
num - 1
).num
pages with the current page as centered as possiblegroupBy
. If no groupBy
was used, it is the current page number as a string.x
articles).pagination.pages[0]
.pagination.pages[pagination.pages.length - 1]
.For example, in Jade:
block content
each file in pagination.files
article.content
header.header
small.header-metadata
time.timestamp(datetime=file.date)= moment(file.date).format('MMMM D, YYYY')
h2.content-title
a(href='/' + file.path)= file.title
section.content-article!= file.snippet
nav.navigation.cf
if pagination.previous
a.btn.pull-right(href='/' + pagination.previous.path)
| Newer
i.icon-right-dir
if pagination.next
a.btn.pull-left(href='/' + pagination.next.path)
i.icon-left-dir
| Older
MIT
FAQs
A Metalsmith plugin for paginating arrays and collections.
We found that metalsmith-pagination demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.