まんぷくブログのシステムをJekyll 3.0に移行
Jekyll 3.0が10月26日リリースされました。
Jeykyll 3.0 beta1が1月に出てから、その後音沙汰がなかった我らがJekyll 3.0が、とうとう正式にリリースされました。何はともあれ開発者の皆様にお礼を申し上げます。
beta1が出た直後はちょくちょく[公式サイトのお知らせページ][http://jekyllrb.com/news/]をチェックをしていたのですが、しばらく動きがないうちにすっかり忘れちゃってました(笑)。先日OS XをYosemiteからEl Capitanにアップグレードしたついでに、brewやrbenv、ruby、gem等を最新のものに更新していて、偶然気がついた次第です。
まずは変更せずに実行してみた
jekyll s
を実行して早速様子を見てみると以下ようなワーニングメッセージが出ました。メジャーバージョンが上がっていますので、さすがに変更無しではうまく動作しない部分があるようです。
$ jekyll s
Configuration file: /jekyll/_config.yml
Deprecation: You appear to have pagination turned on, but you haven't included the `jekyll-paginate` gem. Ensure you have `gems: [jekyll-paginate]` in your configuration file.
Source: /jekyll
Destination: /jekyll/_site
Incremental build: disabled. Enable with --incremental
Generating...
Deprecation: Collection#map should be called on the #docs array directly.
Called by /jekyll/_plugins/rssgenerator.rb:43:in `block in generate'.
Deprecation: Collection#each should be called on the #docs array directly.
Called by /jekyll/_plugins/rssgenerator.rb:45:in `block in generate'.
Deprecation: Document#title is now a key in the #data hash.
Called by /jekyll/_plugins/rssgenerator.rb:47:in `block (3 levels) in generate'.
Deprecation: Document#excerpt is now a key in the #data hash.
Called by /jekyll/_plugins/rssgenerator.rb:49:in `block (3 levels) in generate'.
Deprecation: Document#title is now a key in the #data hash.
Called by /jekyll/_plugins/rssgenerator.rb:47:in `block (3 levels) in generate'.
Deprecation: Document#excerpt is now a key in the #data hash.
Called by /jekyll/_plugins/rssgenerator.rb:49:in `block (3 levels) in generate'.
以下省略....
問題その一
Configuration file: /jekyll/_config.yml
Deprecation: You appear to have pagination turned on, but you haven't included the `jekyll-paginate` gem. Ensure you have `gems: [jekyll-paginate]` in your configuration file.
どうやらコア部分をよりコンパクトにするためにpaginate機能が外だしになったようで、これはエラーメッセージに書かれている通りに_config.ymlにgmes: [jekyll-paginate
行を追加すればすぐに解決します。
問題その2
Deprecation: Collection#map should be called on the #docs array directly.
Called by /jekyll/_plugins/rssgenerator.rb:43:in `block in generate'.
Deprecation: Collection#each should be called on the #docs array directly.
Called by /jekyll/_plugins/rssgenerator.rb:45:in `block in generate'.
二つ目は自作したプラグインで発生していて、エラーが発生している箇所はいずれも「site.posts」を参照している部分でした。これもメッセージのアドバイス通り以下のように修正すれば解決しました。
問題その3
Deprecation: Document#title is now a key in the #data hash.
Called by /jekyll/_plugins/rssgenerator.rb:47:in `block (3 levels) in generate'.
Deprecation: Document#excerpt is now a key in the #data hash.
Called by /jekyll/_plugins/rssgenerator.rb:49:in `block (3 levels) in generate'.
これも同様にプラグイン内部で発生していたもので、同じくsite.postsに起因していました。格納されているデータがハッシュに変更されたようで、こちらもメッセージ通りに修正することでエラーが出なくなりました。とりあえずサイトが再びビルド出来るようになったので一安心です。3.0になってどう良くなったのかはまだ理解出来ていませんが、何か分かったらまた記事にしたいと思います。
最後に何かの参考なるかもしれないので、diffを貼っときます。
--- a/_plugins/rssgenerator.rb
+++ b/_plugins/rssgenerator.rb
@@ -40,13 +40,13 @@ module Jekyll
maker.channel.link = site.config['url']
maker.channel.description = site.config['description'] || "RSS feed for #{site.config['name']}"
maker.channel.author = site.config["author"]
- maker.channel.updated = site.posts.map { |p| p.date }.max
+ maker.channel.updated = site.posts.docs.map { |p| p.date }.max
maker.channel.copyright = site.config['copyright']
- site.posts.each do |post|
+ site.posts.docs.each do |post|
maker.items.new_item do |item|
- item.title = post.title
+ item.title = post['title']
item.link = "#{site.config['url']}#{post.url}"
- item.description = post.excerpt
+ item.description = post['excerpt']
item.updated = post.date
end
end