docpad-plugin-navlinks

Docpad plugin which adds the ability to generate a navigation bar for documents with links to the next and previous document of a specified collection

npm install docpad-plugin-navlinks
61 downloads in the last week
554 downloads in the last month

NavLinks Plugin for DocPad

Adds the ability to generate a navigation bar for documents with links to the next and previous document of a specified collection for DocPad.

Install

npm install --save docpad-plugin-navlinks

Usage

The purpose of this plugin is to generate a navigation bar for documents with links to the next and previous document of a specified collection. Useful especially for posts.

Setup

Edit the docpad.coffee configuration file.

Identify one o more collections you want add navbar links in the

  collections:
    pages: (database) ->
      database.findAllLive({pageOrder: $exists: true}, [pageOrder:1,title:1])    
    posts: (database) ->
      database.findAllLive({layout:$has:'post'}, [date:-1])

Define collections you want to enable navbar links. You may also specifies collection sorting (-1 for reverse order).

  # Plugins configurations
  plugins:
    navlinks:
      collections:
        posts: -1
        pages: 1

In the eco template (i.e. post.html.eco) add:

    <%- @getNavLinks() %>

You may style the navlinks usign the following css classes:

.navlinks {}

.navlinks-prev {
    float: left;
}

.navlinks-next {
    float: right;
}

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Luca Corbo

npm loves you