1. nyufac
  2. Jekyll Views Router

Overview

HTTPS SSH

Views router for jekyll

Simple router between generator plugins and templates (views).

Installation

Put _00_views_router.rb file in your plugins folder.

Usage

1) Rename your generator plugins classes. E.g. for latest posts generator class should be renamed to LatestPosts, for reading it should be Reading and for bitbucket projects - BitbucketProjects.

2) Use views collection in your generator plugins instead of hardcoding page filenames.

module Reading
  class Reading < Jekyll::Generator
    def generate(site)
      ongoing, done = Book.all.partition(&:ongoing?)

      views(site).each do |view|
        view.data['ongoing'] = ongoing
        view.data['done'] = done
      end
    end
  end
end

3) Specify generator dependencies in your templates with uses parameter:

---
layout: default
uses: [ latest_posts, reading, bitbucket_projects ]
---

Names latest_posts, reading, bitbucket_projects autogenerated from your generator plugins class names.