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

spirit-posts

v1.0.1

Published

A blog post middleware for the Spirit static file generator.

Downloads

6

Readme

Spirit Posts

Summary

A static blog post middleware generator for the [ Spirit Core ] ( http://github.com/alexr-ray/spirit-core) static file generator.

Installation

install through npm .

npm install spirit-posts

Syntax

To use simply add an optional markdown config object to the Spirit Core configuration. And pass it to the spirit-posts middleware to the Spirit Core's use method.

Example

Directory Structure

> = Directory
- = File

> "example"
  - "_config.json"
  > "src"
    > "posts"
      - "a_post.md"
  > "dest"

In _config.json

{
  "src" : "src",
  "dest": "dest",
  "posts" : {
    "src" : "posts",
    "dest": "post",
    "cleanUrls" : true
  }
}

Then simply run the middleware.


var SpiritCore  = require( 'spirit-core' ) ;
var spiritPosts = require( 'spirit-posts' ) ;
var spirit      = new SpiritCore( "./example" ) ;

spirit.use( spiritPosts ) ;

spirit.run( ) ;

var spiritData = spirit.getData( ) ;
var post = spiritData.post[ "a_post" ] ;

console.log( post ) ;

The output directory will look like this.

> = Directory
- = File

  > "example"
    - "_config.json"
    > "src"
      > "posts"
        - "a_post.md"
    > "dest"
      > "post"
        > "a_post"
          - "index.html"

The middleware will use the file data's data property provided by the spirit front matter middleware and will look for these front matter values.

data.draft Boolean :

If set to True it will not write file to destination directory and will store the fileData in draft Object and drafts Array.

Default value is False.

data.tags Array :

Takes an array of strings and will include them into the tags Array and the tag[ "tag string" ] Array.

Default value is [ ] ;

data.slug String :

Takes a String value to represent the slug name of that file when written to destination folder. ( the folders index.html name if clean urls, otherwise the filename ).

Default value is the files base name.

data.date String :

Takes a String that can be parsed by the Date.parse and will use it to sort the drafts and posts Array.

Default value is Date.now( ).


The middleware will also add these properties to the file data Object if the don't exists already.

content String :

The file data's buffer string encoded in utf8.

html String :

The file data's content.

slug String :

The url name for that file.

date String :

The human readable format of the files date.

published Boolean :

A Boolean representation of if the post has been published or not.


The middleware will also expose these properties on the spirit core Object and the spirit site data Object.

post Object :

A collection of all the published files with their relative String file paths ( or slugs ) as keys. And their file data Object as their value.

posts Array :

A list of published file data objects sorted by date. ( from most recent to oldest ).

draft Object :

A collection of all the unpublished files with their relative String file paths ( or slugs ) as keys. And their file data Object as their value.

drafts Array :

A list of unpublished file data objects sorted by date. ( from most recent to oldest ).

tag Object :

A collection of all the tags with the tag String representing their keys and an Array of file data objects with that tag sorted by date. ( from most recent to oldest ) ;

tags Array :

A list of String tag names.

For more information please visit Spirit Core .

Hand made in San Francisco California by Alex Ray .