No commit activity in last 3 years
No release in over 3 years
Sensible defaults for a Nanoc site.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.3
~> 0.12.2
~> 1.0.1
~> 1.21
~> 3.6.1
~> 1.5.2
~> 1.0
~> 10.0.3
~> 1.5.1
~> 1.0.15
~> 1.3.0
 Project Readme

NanocStarterSet

(In development. Pull requests welcome!)

NanocStarterSet is a gem that makes it easy to start a Nanoc site with sensible defaults and some handy batteries included. It uses:

  • kramdown for Markdown parsing with fenced code blocks.
  • compass for SCSS and a large library of helpful mixins / helpers.
  • rainpress for compressing CSS.
  • uglifier for compressing JavaScript.
  • typogruby for nice typography.

I recommend using prettify if you want to syntax-highlight Markdown's fenced code blocks.

The included helpers and nanoc rules give you things like:

  • A /css/all.css file that contains a joined and compressed copy of all your CSS files.
  • A /js/all.js file that contains a joined and compressed copy of all your JavaScript files.
  • ERB processing of your source files, if you suffix it with ".erb"

TODO

  • Include a sensible default layout, and:
    • Include all.js and all.css
    • Include prettify
  • Remove the all.js / all.css hackery
  • Add more sensible defaults around blogs / pages
  • Add CoffeeScript support
  • Create a one-command site creator
  • Support backtick fenced code blocks

Installation

% gem install nanoc_starter_set
% nanoc create-site my_site

Usage

In your site's root, create a Gemfile:

source "https://rubygems.org"
gem 'nanoc_starter_set'

Install the gems:

$ bundle install

Add the following to lib/default.rb:

require 'nanoc_starter_set'

And in your Rules file, at the top:

extend NanocStarterSet::Rules

Recommended layout

<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width" />
    <meta name="generator" content="nanoc <%= Nanoc::VERSION %>"> 

    <title><%= @item[:title] %></title>

    <link rel="stylesheet" href="/css/all.css">
  </head>
  <body class="<%= body_class %>">
    <div id="main">
      <%= yield %>
    </div>
    <script src="/js/all.js"></script>
    <script>
      /* Highlight all <pre> tags with a <code> child */
      var preTags = document.getElementsByTagName( "pre" );
      for (var i = 0; i < preTags.length; i += 1) {
        var preTag = preTags[i];
        var codeTag = preTag.children[0];
        if ( codeTag && codeTag.tagName == "CODE" ) {
          preTag.className += " prettyprint";
        }
      }
      prettyPrint();
    </script>
  </body>
</html>

Markdown notes

Kramdown does fenced code blocks like this:

~~~ css
.my-example {
  color: red;
}
~~~

CSS

Create an 'all' CSS file:

$ mkdir -p content/css
$ touch content/css/all.scss.erb

With these contents:

---
all: true
---

<% asset_items( :css ).each do |item| %>
  <%= item.compiled_content %>
<% end %>

You can change the order of files by prefixing a number to their name: "01_reset.css", etc.

JS

Create an 'all' JS file:

$ mkdir -p content/js
$ touch content/js/all.js.erb

With these contents:

---
all: true
---

<% asset_items( :js ).each do |item| %>
  <%= item.compiled_content %>
<% end %>

You can change the order of files by prefixing a number to their name: "01_jquery.js", etc. Otherwise, it's they're included in alphabetical order.

Misc.

Read the source of the gem to see what other functions it gives you. Setup and integration and documentation could be much easier, of course. It's just a hack to make my life easier.