Replacing Jekyll YAML headers with Org mode buffer settings

I took a quick look at what would be required to avoid having to use YAML headers for Jekyll and using only Org mode buffer settings to set the layout, title from a Jekyll post.

module Jekyll
 class Post
    def read_yaml(base, name, opts = {})
      self.content = File.read_with_options(File.join(base, name),
                                            merged_file_read_opts(opts))
      self.data ||= {}

      org_text = Orgmode::Parser.new(self.content)
      org_text.in_buffer_settings.each_pair do |key, value|
        self.data[key.downcase] = value
      end

      self.extracted_excerpt = self.extract_excerpt
    rescue => e
      puts "Error converting file #{File.join(base, name)}: #{e.message}"
    end
  end
end

This way, instead of having to write

---
title: something
---

I can just continue to use Org mode syntax:

#+title: Replacing Jekyll YAML headers with Org mode buffer settings

My fork of jekyll-org which has this feature enabled is here.

Update [2013-12-07 Sat]

I did some modifications again to plugin for converting Org mode texts:

The resulting plugin is here:

require 'org-ruby'

module Jekyll
  # This overrides having to use YAML in the posts
  # and instead use in buffer settings from Org mode
  class Post
    def read_yaml(base, name, opts = {})
      content = File.read_with_options(File.join(base, name),
                                       merged_file_read_opts(opts))
      self.data ||= {}

      org_text = Orgmode::Parser.new(content)
      org_text.in_buffer_settings.each_pair do |key, value|
        # Remove #+TITLE from the buffer settings to avoid double exporting
        org_text.in_buffer_settings.delete(key) if key =~ /title/i
        buffer_setting = key.downcase
        self.data[buffer_setting] = value
      end

      # Disable Liquid tags from the output
      self.content = <<ORG
{% raw %}
#{org_text.to_html}
{% endraw %}
ORG
      self.extracted_excerpt = self.extract_excerpt
    rescue => e
      puts "Error converting file #{File.join(base, name)}: #{e.message} #{e.backtrace}"
    end
  end

  # Based from https://github.com/eggcaker/jekyll-org
  class OrgConverter < Converter
    safe true
    priority :low

    def matches(ext)
      ext =~ /org/i
    end

    def output_ext(ext)
      ".html"
    end

    def convert(content)
      content
    end
  end

  module Filters
    def restify(input)
      site = @context.registers[:site]
      converter = site.getConverterImpl(Jekyll::OrgConverter)
      converter.convert(input)
    end
  end
end