Switch to nanoc

Yesterday, after my exam, I finally finished the transition of my blog to nanoc. I'm very happy to have a statically generated blog, instead of WordPress, in which I need to invest more time to keep it secure then I actually write posts.

And, as you see, this blog is transitioning to English now. I'm not quite sure how I'll kind of separate the old Dutch part from the English, but we'll see. It's not that important now.

With wp2nanoc, I imported my old WordPress posts. I needed to do some changes however, as the options with an argument don't work. I didn't want the conversion however, so I deleted it manually. The id's didn't work either, but I fixed it.

Those post don't suffice, however, as most of then are bbcode. I'm using pandoc for Markdown, but pandoc doesn't support bbcode. I found however this post which does the trick:

require 'rubygems'
require 'bb-ruby'

class BbcodeFilter < Nanoc3::Filter
  identifier :bbcode

  def run(content, args)


This however, doesn't suffice, as some other tags have been used in the past. I'm not sure however what I'm going to do about code blocks, as pandoc does clearly a much better job.

Another thing I definitely wanted was pagination. I found the code of this blog, which has helped me tremendously. I did however some optimisations. For example, I do use pagination on categories,too.

module PaginationHelper
  def generate_pages(articles, title, base_url='')
    articles_to_paginate = articles
    pages = (articles.size - 1) / @config[:page_size] + 1
    article_groups = []
    until articles_to_paginate.empty?
      article_groups << articles_to_paginate.slice!(0..@config[:page_size]-1)
    article_groups.each_with_index do |subarticles, i|
      items << Nanoc::Item.new("<%= render 'page', :pages => #{pages}, :page => #{i + 1}, :base_url => \"#{base_url}\" %>", {
        :title => title,
        :created_at => DateTime.now,
        :articles => subarticles
      }, link_for_page(i + 1, base_url))

  def link_for_page(page, base_url='')
    page == 1 ? base_url + '/' : "#{base_url}/page/#{page}"