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

derpjs

v0.2.2

Published

*A simple, bare-bones, file-based blog engine.*

Downloads

18

Readme

Derpjs

A simple, bare-bones, file-based blog engine.

What?

Derp is bascially a glorified markdown parser, and it wants posts in a certain way. Given the following first-post.md:

url: my-first-post

# My First Post

...herpin' the derp...

Derp will give you an object that looks like this:

{
  title: "My First Post",
  url: "my-first-post",
  content: "<p>...herpin' the derp...</p>"
}

Derp takes the first heading 1 it finds and sets it to be the post's title. Anything before that heading is treated as a meta section. Simply add the key:values you want, and they'll come out in the post object:

url: a-new-post
tags: derp, markdown, another tag
date: 15 June 2014

# A new post

...
{
  title: "A new post",
  url: "a-new-post",
  tags: ['derp', 'markdown', 'another tag'],
  date: "Sun Jun 15 2014 21:05:39 GMT+0100 (BST)",
  content: "<p>...</p>"
}

Derp treats certain meta keys in certain ways:

  • the url meta becomes the url slug for the post, and is the only meta which is required. (Posts without URLs are ignored — think of it as a primitive draft system)
  • a tags key with a comma-delimmited list will become an array of tags
  • a date will be parsed as a javascript date

Other than those, add whatever meta you want!

Also, it'll watch for changes in the post directory, making sure to keep everything updates for you.

Why?

I needed a blog engine for my site, and wanted an excuse to play around with ES6 generators, node streams, and regex. I drew some heavy inspiration from @jsantell's poet.

Basic setup

  1. Install Node
  2. npm install derpjs

Here's a basic (and contrived) example:

var express = require('express');
var app = express();
var derp = require('derpjs');

derp.setup();

app.get('/', function(req, res) {
  res.send(derp.getAllPosts()); // What, you don't like JSON?
});

app.get('/:url', function(req, res, next) {
  var post = derp.getPost(req.params.url);
  if (!post) res.send(404);
  res.send(post);
});

app.listen(3000);

For more real-wordl examples, see the koa and express examples.

API

derp.setup([options])

Parses all the posts, and sets up a watcher on the posts directory to keep track of file changes. Optionally pass in an options hash (checkout the defaults).

derp.getPost(path)

Returns a post that matches the given path (where the path is a relative url defined on a post).

derp.getAllPosts([sortFn])

Returns an array containing all the posts. The array is not sorted, so this is up to you.

Thanks to...