roots-posts v0.2.1
Roots Posts
Roots Posts adds blogging with Markdown and Frontmatter to Roots.
Installation
- make sure you're in your roots project directory
npm install roots-posts --savemodify your
app.coffeefile to include the extensionposts = require 'roots-posts' module.exports = extensions: [posts(folder: 'posts', layout: 'post')]
Usage
Once you've configured the extension, Roots will search the specified folder for blog posts.
Each file in that folder should be a Markdown file with a name following the pattern:
/posts/2015-05-04-this-is-a-blog-post.mdEach post will be rendered with the specified layout (in this case views/post.jade) and from the layout you can access a post variable with the title, date, body, and other metadata from the post.
extends layout
block content
h3.post-title= post.title
.post-body!= post.bodyPost Listings
You can also list posts in any of your templates by using one of two build-in helper methods:
posts.byTitle()lists posts alphabetically by titleposts.byDate()lists posts by date in reverse chronological order
The name of the collection is based on the folder. So if you configure the extension with posts(folder: 'posts') you will be able to use posts.byDate() in templates. If you configure the extension with posts(folder: 'docs'), you'll use docs.byDate() in templates.
.post-listing
each post in posts.byDate()
h3.title
a.post-title(href=post.permalink)= post.title
.body!= post.bodyLicense
This extension is published under the MIT License