ザキンコのブログ

ザキンコの日記のはてなブログ版です。

nanoc 4.1

久々にrubyとnanoc(http://nanoc.ws/)をアップデートしたら、今使ってる古いnanocのプロジェクトが動かなくなったので少し調整した。
前は文字化けしたりhtml以外のファイルを自動処理しないようにする設定が面倒だったが、今のバージョンは作業が減りました。
文字化けはUTF-8でhtmlを作っていればしなくなったし、何でもフォルダー作ってindex.htmlを作っちゃう設定は、Ruleファイルのrouteを少し書き換えれば大丈夫。
html以外のファイルはそもそも処理しないように変わってました。
25ページもある自分が管理しているホームページが一瞬で更新できるので便利に使っています。
以下、Ruleファイルの変更点メモ。

#!/usr/bin/env ruby

compile '/**/*.html' do
  layout '/default.*'
end

# This is an example rule that matches Markdown (.md) files, and filters them
# using the :kramdown filter. It is commented out by default, because kramdown
# is not bundled with Nanoc or Ruby.
#
#compile '/**/*.md' do
#  filter :kramdown
#  layout '/default.*'
#end

route '/**/*.{html,md}' do
  if item.identifier =~ '/index.*'
    '/index.html'
  else
    # item.identifier.without_ext + '/index.html' # これをコメントに
    item.identifier.to_s # これを追加
  end
end

compile '/**/*' do
  write item.identifier.to_s
end

layout '/**/*', :erb