Have ideas to improve npm?Join in the discussion! »

    spirit-posts

    1.0.1 • Public • Published

    Spirit Posts

    Summary

    A static blog post middleware generator for the 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 .

    Install

    npm i spirit-posts

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar