npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paperpress

v1.2.1

Published

A static pages generator for Node.js.

Downloads

42

Readme

Paperpress

Build Status Coverage Status Dependency Status NPM version

Paperpress is a static pages generator for Nodejs.

NPM

This library will allow you to have a blog or static pages in markdown/html on top of any application with express, koa or any other Node.js http server.

For feature request, contact @Siedrix on twitter or github.

TL;DR

Paperpress will convert a directory structure of markdown files into items that you can use in your application. This items will be sorted in collections.

Install

npm install paperpress

Basic usage

Create a Paperpress instance

var Paperpress = require('paperpress')

var paperpress = new Paperpress({
  baseDirectory: 'static'
})

paperpress.load()

Use baseDirectory to specify where are your Paperpress files. Default value is static

Then you can use the items in a express app like this:

app.get('/blog', function (req, res) {
  var articles = paperpress.getCollection('articles')

  res.render({articles:articles})
})

For more information check the examples.

Warning: Load function is a sync function.

Markdown parser

Paperpress use Remarkable to parse the markdown files. You can use remarkableOptions to specify your custom options.

var Paperpress = require('paperpress')

var paperpress = new Paperpress({
  remarkableOptions: {/* Your Remarkable options */}
})

The default value is:

{
  html: true,
  linkify: true,
  highlight: function (code) {
    return highlighter.highlightAuto(code).value
  }
}

Paperpress structure

Paperpress has 3 concepts: Collections, Items and Hooks.

Collections

This are folders located directly under the baseDirectory and help organice our items in diferent groups.

Suggested directories:

  • /articles this folder will contain all the blog posts of the application.
  • /pages this folder will contain all the pages of the application.
  • /snippers this folder will contain all the snippets of the application, usually single files.

Items

Inside each of your collection folders you can have 2 diferent types of items, the once based on a directory structure and the once based on a single markdown file.

Items as directory

  • info.json This file needs to have title and date.
  • content.md This is the main content of the article, it should be written in mark up.

Items as file

  • [ITEM_NAME].md This file will be converted into an item with title, slug, path and content.

The reason to have a the directory style is to allow more configuration, since you can add any atributes that you want to the info.json file and to modify a path or slug in a particular way.

Hooks

You can declare hooks to modify the items after they are loaded.

var paperpress = new Paperpress({})

paperpress.addHook(function (item) {
  item.loadDate = new Date()
})

Useful snippets for paperpress

Find all items in a collection
var articles = paperpress.getCollection('articles')
Find all items in multiple collections
var pagesAndSnippets = paperpress.getCollections(['pages', 'snippets'])
Find one item in paperpress
var items = paperpress.items.find(function(item){
  return item.path === '/home'
})

Collaborators

License

Released under the MIT license.