#!/usr/bin/env ruby preprocess do @items.each do |item| if item.identifier.to_s.end_with?(".md") && !item.binary? begin title = item.raw_content.match(/^[#] .*$/s).to_s title.gsub!('# ', '') item[:title] = title unless title.empty? # Encoding errors happen on some files for some reason, so we # rescue them. rescue Encoding::CompatibilityError puts "Encoding error" end end end end compile '/**/*.html' do layout '/default.*' end compile '/**/*.md' do filter :redcarpet, renderer: HTML, options: { fenced_code_blocks: true, footnotes: true, lax_spacing: true, no_intra_emphasis: true, space_after_headers: true, strikethrough: true, superscript: true, tables: true } layout '/default.*' filter :md_to_html_ext filter :edit_on_gitlab_link end compile '/**/*.scss' do filter :sass, syntax: :scss write item.identifier.without_ext + '.css' end compile '/index.*' do filter :erb layout '/home.*' write '/index.html' end compile '/sitemap.*' do filter :erb write '/sitemap.xml' end compile '/robots.*' do filter :erb write '/robots.txt' end route '/**/*.scss' do item.identifier.without_ext + '.css' end route '/**/*.{html,md}' do if item.identifier =~ '/index.*' '/index.html' else item.identifier.without_ext + '.html' end end compile '/**/*' do unless item.identifier.ext == 'scss' write item.identifier.to_s end end # Leave the favicon alone. passthrough '/favicon.ico' # Let's Encrypt challenge. passthrough '/.well-known/**/*' layout '/**/*', :erb