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

blogz

v2.2.1

Published

Read a directory of files, get a blog data structure.

Downloads

18

Readme

 ______   _        _______  _______  _______ 
(  ___ \ ( \      (  ___  )(  ____ \/ ___   )
| (   ) )| (      | (   ) || (    \/\/   )  |
| (__/ / | |      | |   | || |          /   )
|  __ (  | |      | |   | || | ____    /   / 
| (  \ \ | |      | |   | || | \_  )  /   /  
| )___) )| (____/\| (___) || (___) | /   (_/\
|/ \___/ (_______/(_______)(_______)(_______/
                                             

Read a directory of files, get a blog data structure. Used in connect-blog.

Directory Layout

All you need to do is create two files for each post: first-post.json and first-post.md.

e.g. first-post.json:

{
  "title"    : "Intro to JavaScript, React and Redux",
  "date"     : "2016-08-10T22:05:56Z",
  "category" : "deep-dive",
  "tags"     : [ "javascript", "react", "redux" ]
}

The minimal amount of data you need to provide just consists of title and date.

e.g. first-post.md:

This is a deep-dive into JavaScript, React and Redux.

You can put any field you like into the JSON file and it will appear in the meta info of each post (see below for each posts structure once it has been processed).

Synopsis

This will return a data structure of the content from the local blog directory (the dir option, required). The domain option is also required so that we can provide full URLs inside the RSS and Atom feeds.

var blogz = require('blogz');

var blog  = blogz({
    dir    : __dirname + '/blog',
    domain : 'example.com',
});

console.log(blog);

If you want to see all levels in the returned data structure, do this:

var util = require('util');
console.log(util.inspect(blog, { depth : null }));

Default Options

var defaults = {
    title       : '',
    description : '',
    base        : '',
    latestCount : 10,
    authorName  : '',
    authorEmail : '',
};

You may override any of these defaults in the options.

  • title : used in the RSS and Atom feeds
  • description : used in the RSS feed
  • base : where the blog will be mounted on the server (e.g. /blog or /misc). If left blank it defaults to the empty string, which means at the root of the server. Don't add a trailing slash.
  • latestCount : the number of posts to store in the latest list returned
  • authorName : used in the Atom feed
  • authorEmail : used in the Atom feed

Overall Layout

{
    posts : [ ... an array of posts ... ],
    post : {
        ... an object of posts, using the base filename as the key ...
    },
    pages : [
        ... an array of arrays (each of `latestCount` long) containing posts ...
    ],
    latest : [
        ... an array of posts containing at most, `latestCount` posts ...
    ],
    archive : {
        '2013' : {
            '01' : [
                ... an array of posts published in this year/month ...
            ],
            ...etc...
        },
        ...etc...
    ],
    tag : {
        'my-tag' : [ ... an array of posts ... ],
        ...etc...
    },
    category : {
        'my-category' : [ ... an array of posts ... ],
        ...etc...
    },
    rss : '...', // The RSS feed for this blog
    atom : '...', // The Atom feed for this blog
    json : '...', // The JSONFeed for this blog
}

Post Layout

Each post looks like this:

{
    'name' : '...', // The basename of the file
    'meta' : {
        // ... any fields you put in `$name.json`, including title, tags and category
        moment : ..., // a MomentJS object with the published date
        year : '2016', // the year in string format
        month : '03', // the month as a two digit string
        day : '12', // the day as a two digit string
        monthname : 'March', // the month as a string
        day : ..., // a MomentJS object with the published date
    },
    content : '...', // the plain text content from `$name.md`
    html : '...', // the HTML markup generated from `$name.md`
    next : ..., // a var pointing to the next post
    prev : ..., // a var pointing to the prev post
}

Author

Written by Andrew Chilton - Twitter - GitHub.

License

(Ends)