Sha256: 2456a8f9148f6252d7a0554fca5dc81ac9153d291cbd85e0f56e2b93e88566f9

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

require 'middleman-core'
require 'middleman-hatenastar/generator'

module Middleman
  module Hatenastar
    class Extension < ::Middleman::Extension
      option :token,      nil,    'Your hatenastar token.'
      option :uri,        'h3 a', 'Permarink of the entry.'
      option :title,      'h3',   'Entry title.'
      option :container,  'h3',   'Set hatenastar to after of the this tag.'
      option :entry_node, 'div.section', 'Unit of each entry,'

      def initialize(app, options_hash={}, &block)
        super

        if options[:token] == nil
          raise ArgumentError, 'Hatenastar token is required.'
        end

        @generator = ::Middleman::Hatenastar::Generator.new(options)
      end

      expose_to_template :hatenastar_tag

      def hatenastar_tag(uri: nil, title: nil, container: nil, entry_node: nil)
        @generator.generate(uri: uri, title: title, container: container, entry_node: entry_node)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-hatenastar-0.2.0 lib/middleman-hatenastar/extension.rb
middleman-hatenastar-0.1.0 lib/middleman-hatenastar/extension.rb