lib_path = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)

Sass::Script::Number.precision = [10, ::Sass::Script::Number.precision].max

set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'

set :markdown_engine, :redcarpet
set :markdown, fenced_code_blocks: true, smartypants: true, with_toc_data: true

activate :directory_indexes
set :trailing_slash, false

activate :livereload, no_swf: true
activate :syntax

activate :blog do |blog|
  blog.permalink = 'articles/{title}/index.html'
  blog.taglink = 'tags/{tag}/index.html'
  blog.year_link = '{year}/index.html'
  blog.month_link = '{year}/{month}/index.html'
  blog.day_link = '{year}/{month}/{day}/index.html'

  blog.sources = 'posts/{year}-{month}-{day}-{title}.html'

  blog.layout = 'article'
  blog.summary_separator = /<!--\s?more\s?-->/
  blog.summary_length = BigDecimal::INFINITY

  blog.default_extension = '.md'

  blog.tag_template = 'tag.html'
  blog.calendar_template = 'calendar.html'

  blog.paginate = true
  blog.per_page = 10
  blog.page_link = 'page/{num}'
end

configure :build do
  activate :gzip
  activate :minify_css
  activate :minify_html
  activate :minify_javascript
  activate :asset_hash
  activate :sitemap, hostname: 'http://tabolario.com'

  activate :imageoptim do |options|
    options.pngout = false
  end
end

activate :deploy do |deploy|
  deploy.method = :git
  deploy.remote = 'deploy'
  deploy.branch = 'master'
end
